Why does solve function return an empty value in a for cycle?
3 views (last 30 days)
Show older comments
Giorgio Ceresoli
on 29 May 2020
Commented: Giorgio Ceresoli
on 29 May 2020
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
3 Comments
Accepted Answer
darova
on 29 May 2020
You have cubic equation
It means that you have 3 roots
try
T_gp_out(i)=double(sol(1)); % choose first root
More Answers (0)
See Also
Categories
Find more on Number Theory 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!