Fsolve Error! Need help- Using Fsolve to solve system of non-linear equations.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Collin Pautsch
le 18 Mar 2019
Réponse apportée : Alex Sha
le 22 Avr 2019
% ***Function script
cpa=1.005;
cpg=1.148;
Qin=801.4;
t2=401;
t1=294.11;
p1=101.4;
p2=2.5*p1;
px=p2;
p3=.94*px;
p5=p1;
nreg=.8;
nc=.82;
nt=.85;
function F=myfun(x)
F=[x(10)-cpa*(t2-t1);
x(10)-cpg*(x(2)-x(3));
x(9)-cpg*(x(3)-x(4));
Qin-cpg*(x(2)-x(1));
nreg*(x(4)-t2)-(x(1)-t2);
nc*(t1-t2)-(t1-x(5));
nt*(x(2)-x(6))-(x(2)-x(3));
nt*(x(3)-x(7))-(x(3)-x(4));
x(5)-(2.5^(.28571429)*t1);
x(6)-((x(8)/p3)^(.24981245)*x(2));
x(7)-(p5/x(8))^(.24981245)*x(3)];
end
% ****Solver Code
x0=[440;1000;900;850;380;890;800;160;110;110];
options = optimoptions('fsolve','display','iter');
[x,fval]= fsolve(@project2,x0,options);
3 commentaires
Réponse acceptée
madhan ravi
le 18 Mar 2019
Modifié(e) : madhan ravi
le 18 Mar 2019
Make the below changes in your code:
[x,fval]= fsolve(@(x)myfun(x,cpa,cpg,Qin,t2,t1,p1,p2,px,p3,p5,nreg,nc,nt),x0,options);
function F=myfun(x,cpa,cpg,Qin,t2,t1,p1,p2,px,p3,p5,nreg,nc,nt)
Note: You finally get a message that No solution found. Maybe it has something to do with the initial guess but this answer clears all the errors in your code. You would have to figure it out by yourself.
3 commentaires
Plus de réponses (1)
Alex Sha
le 22 Avr 2019
Hi, your equations seems to be Contradictory:
"nc*(t1-t2)-(t1-x5)" lead to x5=381.7598
while "x5-(2.5^(.28571429)*t1)" lead to x5=382.126307902248
it is why you can not get accurate solution.
0 commentaires
Voir également
Catégories
En savoir plus sur Linear Algebra dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!