Failure in initial objective function evaluation. FSOLVE cannot continue.

조회 수: 3 (최근 30일)
sara
sara 2022년 10월 3일
댓글: sara 2022년 10월 25일
Hi all,
I'm trying to solve a non linear, parametric system of equations.
Here my myfun_driver.m file containing the call to the function with fsolve:
fun = @root7d;
x0 = [0,0];
x = fsolve(fun,x0);
Here the root7d.m file where I defined the function and parameters (the main function has a call to othe functions, I don't know if I'm doing well):
%parameters
Vp=100;
Kp=0.5;
q=1;
phi=0.006;
MIN=1;
N1=10;
gb=0.8;
gp=0.45;
g1=0.6;
g2=0.5;
g3=0.6;
gf=0.75;
arb=1-ar;
ar=0.2;
r1=0.8;
eps2=0.02;
rho = @(x,vp,kp,gp,gb,MIN,N1)( (1-gp)* vp*x(1)/(kp+x(1))...
+ (1-gb)* (MIN*exp(x(1)/N1)*x(2)));
G1 = @(x,ar,eps2)((ar*x(2)+(1-ar)*x(2))/(eps2^2 + (ar*x(2)+(1-ar)*x(2))^2));
function F = root7d(x,vp,kp,q,phi,r1,MIN,N1,gb,ar,arb)
F(1) = -vp*x(1)/(kp+x(1))*q*x(2) +q*rho(x,gp,gb) + phi - r1*MIN*exp(x(1)/N1)*x(2);
F(2) = gb*r1*MIN*exp(x(1)/N1)*x(2) - r1*G1(x,ar)*arb*x(2)/(ar*x(2)+(1-ar)*x(2));
end
I don't know why I obtain the following message: Failure in initial objective function evaluation. FSOLVE cannot continue.

채택된 답변

Torsten
Torsten 2022년 10월 3일
편집: Torsten 2022년 10월 3일
fun = @root7d;
x0 = [10,10];
x = fsolve(fun,x0)
Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient.
x = 1×2
12.3661 0.5385
fun(x)
ans = 1×2
1.0e-12 * -0.2036 0.0266
function F = root7d(x)
%parameters
vp=100;
kp=0.5;
q=1;
phi=0.006;
MIN=1;
N1=10;
gb=0.8;
gp=0.45;
g1=0.6;
g2=0.5;
g3=0.6;
gf=0.75;
ar=0.2;
arb=1-ar;
r1=0.8;
eps2=0.02;
rho = ( (1-gp)* vp*x(1)/(kp+x(1)) + (1-gb)* (MIN*exp(x(1)/N1)*x(2)));
G1 = ((ar*x(2)+(1-ar)*x(2))/(eps2^2 + (ar*x(2)+(1-ar)*x(2))^2));
F(1) = -vp*x(1)/(kp+x(1))*q*x(2) +q*rho + phi - r1*MIN*exp(x(1)/N1)*x(2);
F(2) = gb*r1*MIN*exp(x(1)/N1)*x(2) - r1*G1*arb*x(2)/(ar*x(2)+(1-ar)*x(2));
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by