Info
此问题已关闭。 请重新打开它进行编辑或回答。
Help with a two variables equation?
1 次查看(过去 30 天)
显示 更早的评论
Hi there, Im trying to create a 3D graph of the Constant Surface Heat flux in a material. The equation is in the pic i added. The thing is, i get problems with multiplying the matrices (x and t).. What am i doing wrong? is there any one who can help write this code? Thank you! (the only variables are x and t, all others are constant.)
2 个评论
Star Strider
2014-12-21
Posting your code would help significantly.
We’re good, but we can’t guess what code you’ve written.
回答(1 个)
Roger Stafford
2014-12-22
In the line
T(x,t)=((2*q)/(k))*......
if T is to be a matrix of values, then the 'x' and 't' values must be indices which are positive integers, and that is not the case with your code. For generating a surface in 3D you should use 'meshgrid' or 'ndgrid' to create a grid of value pairs and then call on 'surf'.
[x,t] = meshgrid(0:0.01:10,0:0.01:10);
T = ((2*q)/(k))*......
surf(x,y,T)
Also I notice several discrepancies between the image of "T(x,t) = ..." equation and the equation you have coded:
1) The -Ti on the left should become +Ti on the right.
2) exp((-(x.^2))/4*alpha*t') should be exp(-x.^2./(4*alpha*t)).
3) x/(sqrt(2*alpha*t)) should be x./(2*sqrt(alpha*t)).
Also it was not necessary to convert the erfc to 1-erf, since matlab already has an erfc function.
2 个评论
Roger Stafford
2014-12-22
编辑:Roger Stafford
2014-12-22
You didn't take my and Mohammad Abouali's advice on 2):
2) exp((-(x.^2))/4*alpha*t') should be exp(-x.^2./(4*alpha*t)).
Without that added 'dot' it would give you the error message. Also you are multiplying by alpha*t here and the operation shown in your original image requires that you divide by these quantities.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!