MATLAB: Does solve function return an empty value in a for cycle

MATLABsolve

for i=1:N
syms Tout
sol=solve (energy_balance,Tout,'Real',true, 'IgnoreAnalyticConstraints',true);
T_gp_out(i)=double(sol);
end
Solve function returns an empty value at the second iteration of the for cycle which i am using.
When the solve function is run separately outside the for cycle it returns a real value.
I can't understand what is going wrong when all inputs and syntax are correct.
Should I define a syms vector function outside the for cycle?
Can someone help me?
Thanks in advance.
Giorgio Ceresoli

Best Answer

You have cubic equation
It means that you have 3 roots
try
T_gp_out(i)=double(sol(1)); % choose first root
Related Question