fsolve in a for loop
Show older comments
I am trying an analytical solution from nonlinear equation for a transient temperature problem. I call the function as
fun = @funhouse;
x0 = [1,1]';
options = optimoptions('fsolve','Display','iter');
[x,fval] = fsolve(@funhouse,x0,options);
And the function is
function F = funhouse(x,Tain)
Ts=18+273;% in K
Ca=11918;% kJ/K
Hae=52.33;%W/K
Hame=41.26;%W/K
Has=87.43;%W/K
Hag=15.54;%W/K
Htot=Hae+Hame+Has+Hag;
tao=17;%W/K
Te=10+273;
t=1;
tao=17;
%FUNHOUSE Summary of this function goes here
% Detailed explanation goes here
F = [x(1)-Ca*(x(2)-Tain)-Hae*(x(2)-Te)-Hame*(x(2)-Te)-Hag*(x(2)-Te)-Has*(x(2)-Te);
x(2)-(Tain-(x(1)/Htot)-(Htot-Has)*Te/Htot-Has*Ts/Htot)*exp(-t/tao)-(x(1)+(Htot-Has)*Te+Has*Ts)/Htot];
end
How to pass Tain as the last value found from the fsolve to the next iteration and save the output in an array.
Answers (1)
Rajeev kamal
on 19 Jan 2016
0 votes
Categories
Find more on MATLAB Coder in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!