Asked by Paul
on 10 Jan 2013

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

Answer by 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)

Log in to comment.

Answer by 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.

Log in to comment.

Opportunities for recent engineering grads.

Apply Today
## 2 Comments

## Image Analyst (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/58430-why-is-matlab-not-solving-for-the-internal-heat-generation-components-of-my-loop#comment_121873

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 valueswhen you get to this line where you calculate T.## Paul (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/58430-why-is-matlab-not-solving-for-the-internal-heat-generation-components-of-my-loop#comment_122166

Sorry I am referring to M_skull and Q_skull. M_skull and Q_skull both are reference values (at 310 Kelvin) determined earlier in the code, but the value of M and Q are temperature dependent and I was trying to solve for this in the above code.

For example the M value is determined by the following equation: M = M_skull*3e^((T-T_art)/10)

where T is the temperature of a node at time m and T_art is a constant value for the arterial temperature.

Log in to comment.