Help with a two variables equation?
Infos
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Afficher commentaires plus anciens

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 commentaires
Star Strider
le 21 Déc 2014
Posting your code would help significantly.
We’re good, but we can’t guess what code you’ve written.
Nir
le 21 Déc 2014
Réponses (1)
Roger Stafford
le 22 Déc 2014
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 commentaires
Nir
le 22 Déc 2014
Roger Stafford
le 22 Déc 2014
Modifié(e) : Roger Stafford
le 22 Déc 2014
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.
Cette question est clôturée.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

