fsolve a output variable is egual equal to the initial value I assigned

조회 수: 4 (최근 30일)
Gaetano Amodio
Gaetano Amodio 2013년 2월 3일
Hi guys I have a "little" problem with Matlab. I'm using fsolve for solve a system, 8 equations and 8 variables, but one of the output variables, b(1), is equal to the initial value I assigned. I tried to change the equations, but the result is always the same, what's happening? I post the code. Thanks for your help.
function F = bottom19(b)
global Fc0 ke k1 k2 k3 k4 k6 e1 e2 e3 e4 e6 T Fsupp Q0 Pco20 R Mc Mcu Mcu2o Mcuo alfa0 Ptot1 T0 tau
F = [1-b(6)-b(7)-b(8); Fc0-b(1)-k1*e1*tau*b(1)*(b(6))^0.54-k6*e6*tau*b(1)*b(8)-ke*tau*b(1); Fsupp*(alfa0-b(2))-k2*e2*b(2)*b(7)-k4*e4*b(2); -Fsupp*b(3)+0.5*Mcu2o/Mcuo*k2*e2*b(2)*b(7)-k3*e3*b(3)*b(7)+0.5*Mcu2o/Mcuo*k4*e4*b(2); -Fsupp*b(4)+2*Mcu/Mcu2o*k3*e3*b(3)*b(7); Q0*Pco20/(R*T0)-b(5)*b(6)*Ptot1/(R*T)-k1*e1*tau*b(1)*(b(6))^0.54/Mc+0.5/Mcuo*k2*e2*b(2)*b(7)+1/Mcu2o*k3*e3*b(3)*b(7)+1/Mc*k6*e6*tau*b(1)*b(8); -b(5)*b(7)*Ptot1/(R*T)+2*k1*e1*tau*b(1)*(b(6))^0.54/Mc-0.5/Mcuo*k2*e2*b(2)*b(7)-1/Mcu2o*k3*e3*b(3)*b(7); -b(5)*b(8)*Ptot1/(R*T)+0.25/Mcuo*k4*e4*b(2)-1/Mc*k6*e6*tau*b(1)*b(8); Fc0/1000+Q0*Pco20/(R*T0)*44-b(1)/1000-ke*tau*b(2)/1000-b(5)*Ptot1/(R*T)*(b(6)*44+b(7)*28+b(8)*32)+Fsupp/1000*(alfa0-b(2)-b(3)-b(4))]
options = optimset('Display','iter','MaxFunEvals',1e10,'TolFun',1e-4,'Maxiter', 1e15,'Algorithm',{'levenberg-marquardt',0.0005});
b0 = [0.1;0.01;0.2;0.005;0.02;0.8;0.03;0.002];
[b,fval,exitflag,output] = fsolve(@bottom19,b0,options);

답변 (1개)

Alan Weiss
Alan Weiss 2013년 2월 4일
편집: Alan Weiss 2013년 2월 4일
I count 9 equations, not 8:
function F = bottom19(b)
global Fc0 ke k1 k2 k3 k4 k6 e1 e2 e3 e4 e6 T Fsupp Q0 Pco20 R Mc Mcu Mcu2o Mcuo alfa0 Ptot1 T0 tau
F = [1-b(6)-b(7)-b(8); % 1
Fc0-b(1)-k1*e1*tau*b(1)*(b(6))^0.54-k6*e6*tau*b(1)*b(8)-ke*tau*b(1); % 2
Fsupp*(alfa0-b(2))-k2*e2*b(2)*b(7)-k4*e4*b(2); % 3
-Fsupp*b(3)+0.5*Mcu2o/Mcuo*k2*e2*b(2)*b(7)-k3*e3*b(3)*b(7)+0.5*Mcu2o/Mcuo*k4*e4*b(2); % 4
-Fsupp*b(4)+2*Mcu/Mcu2o*k3*e3*b(3)*b(7); % 5
Q0*Pco20/(R*T0)-b(5)*b(6)*Ptot1/(R*T)-k1*e1*tau*b(1)*(b(6))^0.54/Mc+0.5/Mcuo*k2*e2*b(2)*b(7)+1/Mcu2o*k3*e3*b(3)*b(7)+1/Mc*k6*e6*tau*b(1)*b(8); % 6
-b(5)*b(7)*Ptot1/(R*T)+2*k1*e1*tau*b(1)*(b(6))^0.54/Mc-0.5/Mcuo*k2*e2*b(2)*b(7)-1/Mcu2o*k3*e3*b(3)*b(7); % 7
-b(5)*b(8)*Ptot1/(R*T)+0.25/Mcuo*k4*e4*b(2)-1/Mc*k6*e6*tau*b(1)*b(8); % 8
Fc0/1000+Q0*Pco20/(R*T0)*44-b(1)/1000-ke*tau*b(2)/1000-b(5)*Ptot1/(R*T)*(b(6)*44+b(7)*28+b(8)*32)+Fsupp/1000*(alfa0-b(2)-b(3)-b(4))] % 9
This might make a difference -- fsolve is designed to work on "square" systems, systems with exactly as many equations as variables.
But you should also read the suggestions in this section of the documentation.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation

카테고리

Help CenterFile Exchange에서 Nonlinear Analysis에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by