getting error , i want to solve 6 equation by fsolve

1 次查看(过去 30 天)

  2 个评论
mahaveer das
mahaveer das 2018-12-16
function F= solar(x)
j=5.67e-8;
M=40;
Cp=4180;
f = 0.88;
L=1;
hci=100;
Aap=1.9;
od=0.03;
e=0.9;
Hab=500;
Tfi=40;
Ta=20;
W=1;
hw=67.83;
Q=x(1);
U=x(2);
hr=x(3);
Tr=x(4);
Tfm=x(5);
Tfo=x(6);
F(1) = Q-Aap*f*(Hab-(pi*od*U*(Tfi-Ta))/(W-od));
F(2) = U-hw-hr;
F(3) = hr-e*j*(Tr+Ta)*(Tr^2+Ta^2);
F(4) = (Tr-Tfm)*(hci*pi*od*L)-M*Cp*(Tfo-Tfi);
F(5) = 2*Tfm-Tfi-Tfo;
F(6) = M*Cp*(Tfo-Tfi)-Q;
end
in command window
x0=[1;1;1;1;1;1];
>> xsol=fsolve(@(x) solar(x),x0)
Undefined function or variable 'cn'.
Error in fsolve (line 230)
cn{3},x,var fuser = feval(funfargin{:});
Caused by:
Failure in initial objective function evaluation. FSOLVE cannot
continue.

请先登录,再进行评论。

回答(2 个)

madhan ravi
madhan ravi 2018-12-16
编辑:madhan ravi 2018-12-16
x0=[1;1;1;1;1;1];
xsol=fsolve(@(x) solar(x),x0) % function call
function F= solar(x) % function definition
j=5.67e-8;
M=40;
Cp=4180;
f = 0.88;
L=1;
hci=100;
Aap=1.9;
od=0.03;
e=0.9;
Hab=500;
Tfi=40;
Ta=20;
W=1;
hw=67.83;
Q=x(1);
U=x(2);
hr=x(3);
Tr=x(4);
Tfm=x(5);
Tfo=x(6);
F(1) = Q-Aap*f*(Hab-(pi*od*U*(Tfi-Ta))/(W-od));
F(2) = U-hw-hr;
F(3) = hr-e*j*(Tr+Ta)*(Tr^2+Ta^2);
F(4) = (Tr-Tfm)*(hci*pi*od*L)-M*Cp*(Tfo-Tfi);
F(5) = 2*Tfm-Tfi-Tfo;
F(6) = M*Cp*(Tfo-Tfi)-Q;
end
Gives:
xsol =
615.3736
67.9034
0.0734
105.2950
40.0018
40.0037
  8 个评论
madhan ravi
madhan ravi 2018-12-16
Mahaveer Das's answer moved here for consistency:
and i also want to make graph between M and Q or other quantity
madhan ravi
madhan ravi 2018-12-16
I have no idea why you get an error , everything works fine for me.

请先登录,再进行评论。


mahaveer das
mahaveer das 2018-12-16
and i also want to make graph between M and Q or other quantity

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by