Why is MATLAB not solving for the internal heat generation components of my loop?
1 view (last 30 days)
Show older comments
I am trying to model 1D transient heat transfer in the brain, however my code is not solving for the M and Q values below. The code is not returning an error but seems to be simply ignoring the values.
elseif 3 < i < 5
T(i,m+1) = T(i,m) + k_skull*del_t_skull/(rho_skull*Cp_skull*del_i^2)*(T(i-1,m)-2*T(i,m)+T(i+1,m))
+ M_skull*3*exp((T(i,m)- T_art)/10) + Q_skull*3*exp((T(i,m)- T_art)/10)* rho_blood*Cp_blood*(T_art - T(i,m));
Note:
del_i = spacing of nodes
del_t_skull = 0.25*del_i^2/alpha_skull;
Where alpha is the thermal diffusvity.
Any help is very much appreciated
2 Comments
Image Analyst
on 10 Jan 2013
Edited: Image Analyst
on 10 Jan 2013
You didn't give the code for solving M and Q - you just gave code for determining T. And you mean M_skull, and Q_skull, right? Well, there is nowhere in your code where you determine M_skull and Q_skull. They're just assumed to already have some values when you get to this line where you calculate T.
Answers (2)
Walter Roberson
on 12 Jan 2013
elseif 3 < i < 5
is evaluated as
elseif ((3 < i) < 5)
The (3 < i) part returns true (1) or false (0), both of which are always less than 5, so your elseif would always be considered to be true.
MATLAB does not have a range-test syntax. Use
elseif (3 < i) & (i < 5)
0 Comments
Roger Stafford
on 12 Jan 2013
Besides the trouble Walter describes, you apparently lack an ellipsis following this line:
T(i,m+1)= T(i,m)+k_skull*del_t_skull/(rho_skull*Cp_skull*del_i^2)*(T(i-1,m)-2*T(i,m)+T(i+1,m)) ...
The way it is now, the line after this with M_skull and Q_skull won't be included in the calculation. but you will get an unwanted display of the results of this line each time it executes.
0 Comments
See Also
Categories
Find more on Thermal Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!