Problem with fsolve?
Afficher commentaires plus anciens
hi guys, I'm trying to solve a 3 equation non-linear system with fsolve, but it always give me an error when i run it. I have F cell of 3 function handle, and that's my input with fsolve. The functions work properly (I tryed to give a random vector of solutions and they gave me a result).
sol0=[0.5 0.3 0.3]
f1=@(sol) exp((P./(R.*T)).*(B(1,1)+0.5.*(sol(2).^2+sol(3).^2+(1-sol(2)-sol(3)).^2+2.*sol(2).*sol(3)+2.*sol(2)*(1-sol(2)-sol(3))+2.*sol(3).*(1-sol(2)-sol(3)))));
f2=@(sol) exp((P./(R.*T)).*(B(2,2)+0.5.*(sol(2).^2+sol(3).^2+(1-sol(2)-sol(3)).^2+2.*sol(2).*sol(3)+2.*sol(2)*(1-sol(2)-sol(3))+2.*sol(3).*(1-sol(2)-sol(3)))));
f3=@(sol) exp((P./(R.*T)).*(B(3,3)+0.5.*(sol(2).^2+sol(3).^2+(1-sol(2)-sol(3)).^2+2.*sol(2).*sol(3)+2.*sol(2)*(1-sol(2)-sol(3))+2.*sol(3).*(1-sol(2)-sol(3)))));
g1=@(sol) exp((1./(R.*T)).*(a./(1+(a.*sol(1)./(b.*(1-sol(1))))).^2));
g2=@(sol) exp((1./(R.*T)).*(b./(1+(b.*(1-sol(1))./(a.*sol(1)))).^2));
fun1=@(sol) (g1(sol).*sol(1).*Ps1)-(f1(sol).*sol(2).*P);
fun2=@(sol) (g2(sol).*(1-sol(1)).*Ps2)-(f2(sol).*sol(3).*P);
fun3=@(sol) (K.*f3(sol).*f2(sol))-f1(sol);
sol=[0 0 0]
F={fun1 fun2 fun3}
sol=fsolve(F,sol0)
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!