FSOLVE GIVES SAME VALUE
Show older comments
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 Comments
JYOTI PRAKASH BEHERA
on 27 Nov 2020
Alan Stevens
on 27 Nov 2020
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
on 27 Nov 2020
Alan Stevens
on 27 Nov 2020
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.
Answers (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
Categories
Find more on Systems of Nonlinear Equations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!