Finding Unknown Parameters from Monod Equations
Show older comments
Hi, new to Matlab and still learning.
I am using a modified code provided by Star Strider.Thanks Star Strider! I am making this as a new post so I can accept this one as well =).
The code is shown below. I got the data from another Matlab post. The equation is as shown in the screenshot: I converted all constants into theta. When I run the code below, I get huge constants that doesn't makes sense. Anything I'm doing wrong? Is it my equations? C0 or theta0? Thank you!

Function Igor_Mour
function C=kinetics(theta,t)
c0=[0.1;9;0.1];
[T,Cv]=ode45(@DifEq,t,c0);
%
function dC=DifEq(t,c)
dcdt=zeros(3,1);
dcdt(1)=-theta(1).*c(1).*c(2)/(theta(2)+c(1));
dcdt(2)= -(1/theta(3)).*theta(1).*c(1).*c(2)/(theta(2)+c(1));
dcdt(3)= (1/theta(4)).*theta(1).*c(1).*c(2)/(theta(2)+c(1));
dC=dcdt;
end
C=Cv;
end
t = [0 3 5 8 9.5 11.5 14 16 18 20 25 27]'
x = [0.0904 0.1503 0.2407 0.3864 0.5201 0.6667 0.8159 0.9979 1.0673 1.1224 1.1512 1.2093]';
s = [9.0115 8.8088 7.9229 7.2668 5.3347 4.911 3.5354 1.4041 0 0 0 0]';
p = [0.0151 0.0328 0.0621 0.1259 0.2949 0.3715 0.4199 0.522 0.5345 0.6081 0.07662 0.7869]';
%Note: x,s and p are combined (in separate columns) to form c.
theta0=[1;1;1;1;1;1];
[theta,Rsdnrm,Rsd,ExFlg,OptmInfo,Lmda,Jmat]=lsqcurvefit(@kinetics,theta0,t,c);
fprintf(1, '\tRate Constants:\n')
for k1 = 1:length(theta)
fprintf(1, '9\t\tTheta(%d) = %8.5f\n', k1, theta(k1))
end
tv = linspace(min(t), max(t));
Cfit = kinetics(theta, tv);
figure(1)
plot(t, c, 'p')
hold on
hlp = plot(tv, Cfit);
hold off
grid
xlabel(Time)
ylabel(Concentration)
legend(hlp, 'C_1(t)','C_2(t)','C_3(t)','C_4(t)', 'Location','N')
end
1 Comment
Alex Sha
on 16 Oct 2022
Hi, 0.07662, one of data for p, should be 0.7662? if so, see the result below:
Sum Squared Error (SSE): 1.43925599360388
Root of Mean Square Error (RMSE): 0.208839215637285
Correlation Coef. (R): 0.982548927303979
R-Square: 0.9654023945462
Parameter Best Estimate
--------- -------------
theta1 0.0214068471653595
theta2 -1.28632596117882
theta3 -0.113732223600425
theta4 -1.55421915737194



Accepted Answer
More Answers (1)
Works for me.
t = [0 3 5 8 9.5 11.5 14 16 18 20 25 27]' ;
x = [0.0904 0.1503 0.2407 0.3864 0.5201 0.6667 0.8159 0.9979 1.0673 1.1224 1.1512 1.2093]';
s = [9.0115 8.8088 7.9229 7.2668 5.3347 4.911 3.5354 1.4041 0 0 0 0]';
p = [0.0151 0.0328 0.0621 0.1259 0.2949 0.3715 0.4199 0.522 0.5345 0.6081 0.7662 0.7869]';
c = [x s p];
theta0=[1;1;1;1;1;1];
options = optimset('MaxFunEvals',100000,'MaxIter',100000);
[theta,Rsdnrm,Rsd,ExFlg,OptmInfo,Lmda,Jmat]=lsqcurvefit(@kinetics,theta0,t,c,[],[],options);
theta
C = kinetics(theta,t)
hold on
plot(t,c,'o')
plot(t,C)
hold off
function C=kinetics(theta,t)
%c0=[0.1;9;0.1];
c0 = [0.0904;9.0115;0.0151];
[T,Cv]=ode45(@DifEq,t,c0);
%
function dC=DifEq(t,c)
dcdt=zeros(3,1);
dcdt(1)=-theta(1).*c(1).*c(2)/(theta(2)+c(1));
dcdt(2)= -(1/theta(3)).*theta(1).*c(1).*c(2)/(theta(2)+c(1));
dcdt(3)= (1/theta(4)).*theta(1).*c(1).*c(2)/(theta(2)+c(1));
dC=dcdt;
end
C=Cv;
end
Categories
Find more on Systems of Nonlinear Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


