FSOLVE GIVES SAME VALUE
이전 댓글 표시
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
2020년 11월 27일
Alan Stevens
2020년 11월 27일
You are trying to solve for x1, x2 and x3, but they only appear in two equations. There can be an infinite number of solutions.
JYOTI PRAKASH BEHERA
2020년 11월 27일
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개)
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)
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
카테고리
도움말 센터 및 File Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!