FSOLVE GIVES SAME VALUE

조회 수: 2 (최근 30일)
JYOTI PRAKASH BEHERA
JYOTI PRAKASH BEHERA 2020년 11월 27일
답변: Matt J 2020년 11월 27일
clc;clearvars;close all; format short g;format compact;
tfinal=30;
pars.D=0.00005611;
pars.x2f=20;
pars.Y=0.4;
pars.beta=0.000055;
pars.k1=0.04545;
pars.alpha=2.2;
pars.mumax=0.000133;
pars.km=1.2;
pars.x3max=50;
csol2=fsolve(@(c) chemofun(c,pars),[5 4.5 15]);
function f=chemofun(c,pars)
f=zeros(3);
x1=c(1);
x2=c(2);
x3=c(3);
mumax=pars.mumax;
x3max=pars.x3max;
km=pars.km;
k1=pars.k1;
mu=((mumax)*x2*(1-(x3/(x3max))))/(km+x2+(x2^2)*(k1));
D=pars.D;
x2f=pars.x2f;
Y=pars.Y;
A=pars.alpha;
B=pars.beta;
f(1)=(mu-(D));
f(2)=(D)*(x2f-x2)-(mu*x1)/(Y);
f(3)=(-1)*(D)*x3+((A)*mu+B)*x1;
end
  댓글 수: 4
JYOTI PRAKASH BEHERA
JYOTI PRAKASH BEHERA 2020년 11월 27일
Mu have x1
Alan Stevens
Alan Stevens 2020년 11월 27일
Actually, it seems to have x2 and x3; but you are right, three equations are involved. The results seem very sensitive to the initial guesses though.

댓글을 달려면 로그인하십시오.

답변 (1개)

Matt J
Matt J 2020년 11월 27일
clc;clearvars;close all; format short g;format compact;
tfinal=30;
pars.D=0.00005611;
pars.x2f=20;
pars.Y=0.4;
pars.beta=0.000055;
pars.k1=0.04545;
pars.alpha=2.2;
pars.mumax=0.000133;
pars.km=1.2;
pars.x3max=50;
fun=@(c) chemofun(c,pars);
opts=optimoptions('fsolve','StepTolerance',1e-12,'FunctionTolerance',1e-12,'OptimalityTolerance',1e-12);
[csol2,fsol2]=fsolve(fun,[5 4.5 15],opts)
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.
csol2 = 1×3
5.9905 5.0238 19.051
fsol2 = 1×3
-8.9331e-12 1.1261e-10 -9.9097e-11
function f=chemofun(c,pars)
f=zeros(1,3); %<-------
x1=c(1);
x2=c(2);
x3=c(3);
mumax=pars.mumax;
x3max=pars.x3max;
km=pars.km;
k1=pars.k1;
mu=((mumax)*x2*(1-(x3/(x3max))))/(km+x2+(x2^2)*(k1));
D=pars.D;
x2f=pars.x2f;
Y=pars.Y;
A=pars.alpha;
B=pars.beta;
f(1)=(mu-(D));
f(2)=(D)*(x2f-x2)-(mu*x1)/(Y);
f(3)=(-1)*(D)*x3+((A)*mu+B)*x1;
end

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by