17 linear and non linear equation

The solver is saying that it has too many input arguments, how it can be solved
function Algebric_equations()
guess=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0];
[result,fval,exit,output]=fsolve(@Algebric_equations,guess);
result;
fval;
Algebric_equations(guess)
output;
end
function fcns= eqns(z)
P_w=z(1);
P_g=z(2);
T_w=z(3);
T_g=z(4);
T_b=z(5);
h_cwgi=z(6);
h_ewgi=z(7);
h_rwgi=z(8);
h-rgoa==z(9);
h_Tgoa=z(10);
U_Tgia=z(11);
U_T=z(12);
U_LS=z(13);
m_w=z(14);
a=z(15);
f_t=z(16);
alfa_eff= z(17);
fcns(1)=-P_w+exp(25.317+5144/(273+T_w));
fcns(2)=-P_g+exp(25.317+5144/(273+T_g));
fcns(3)=-h_cwgi.^3+0.884.^3*((T_w-T_g)+(P_w-P_g)*(T_w+273)/(268900-P_w));
fcns(4)=-h_ewgi+16.28*h_cwgi*((P_w-P_g)/(T_w-T_g))*10E-3;
fcns(5)=-h_rwgi*(T_w-T_g)+(emmi_eff*sigma)*((T_w+273).^4-(T_g+273)^4);
fcns(6)= -h_rgoa*(T_g-T_sky)+(emmi_eff*sigma)*((T_g+273).^4-(T_sky+273).^4);
fcns(7)= -h_Tgoa+h_cgoa+h_rgoa;
fcns(8)=-U_Tgia+((K_g*h_Tgoa/L_g)/((K_g/L_g)+h_Tgoa));
fcns(9)=-U_T+((h_cwgi+h_ewgi+h_rwgi)*U_Tgia)/(h_cwgi+h_ewgi+h_rwgi+U_Tgia);
fcns(10)=-U_LS+U_bs+U_T;
fcns(11)=-m_w+(h_ewgi*(T_w-T_g)/L_ev);
fcns(12)=-T_w*(f_t/a)*(1-exp(-a*t))+(25+273)*(exp(-a*t));
fcns(13)=-a+(U_LS/(m_w*C_pw));
fcns(14)=-f_t+((alfa_eff*I)+(U_LS*T_amb)/(m_w*c_w));
fcns(15)=-alfa_eff+(alfa_bf*h_w/(h_w+h_b))+alfa_wf+(alfa_gf*(h_cwgi+h_ewgi+h_rwgi)/(h_cwgi+h_ewgi+h_rwgi+hTgoa));
fcns(16)=-T_g*(h_cwgi+h_ewgi+h_rwgi+U_Tgia)+(alfa_gf*I)+((h_cwgi+h_ewgi+h_rwgi)*T_w)+(U_Tgia*T_amb);
fcns(17)=-T_b*(h_w)+(alfa_bf*I)+(h_w*T_w);
end

Antworten (1)

Steven Lord
Steven Lord am 14 Jul. 2020

0 Stimmen

function Algebric_equations()
guess=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0];
[result,fval,exit,output]=fsolve(@Algebric_equations,guess);
result;
fval;
Algebric_equations(guess)
output;
end
function fcns= eqns(z)
Don't call fsolve and tell it to solve the system of equations defined inside Algebric_equations from within Algebric_equations itself. If you do fsolve will call Algebric_equations with an input argument, and you've declared that it does not accept any input arguments. Even if you changed it so you could call Algebric_equations with an input, that would call fsolve which calls Algebric_equations which calls fsolve which calls Algebric_equations which ... and you have an infinite loop. Well, at least MATLAB would stop that infinite loop before you crash your machine.
Instead, since you've written the eqns local function to evaluate the system of equations, call fsolve on that function instead of Algebric_equations.
[result,fval,exit,output]=fsolve(@eqns,guess);

1 Kommentar

irfan ashiq
irfan ashiq am 15 Jul. 2020
thanks a lot for your answers bro

Diese Frage ist geschlossen.

Tags

Gefragt:

am 14 Jul. 2020

Geschlossen:

am 20 Aug. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by