Plotting Kinetic Model Monod, Haldane With Parameters
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Regina Maria
am 7 Nov. 2021
Kommentiert: Star Strider
am 8 Nov. 2021
Hello, I want to ask some questions regarding my code (attacthed with name CobaParZhang.m) about plotting graph. When I run the code, it shows error "Index exceeds the number of array elements (1)" like attached bellow.

I would like to plot C(1) (biomass), C(2) (substrate), and C(3) (product) into one figure from these 3 equations below:
, where dX/dt = miu*X
And here are the kinetic parameters:

I am wondering maybe it has some problem with the equation that I am using or the inconsistent unit (biomass and substrate is in g/L, product is in mg/L). Any help or comment or advice about this problem is very welcomed. Thank you so much for your attention.
function CobaParameterZhang
Rentang = linspace(0, 20, 50);
C0 = [0.143; 0.9659; 0.094406];
Miumax=0.5258;
Ks=0.0211;
Kxi=56.6813;
KXI=53.26;
CXm=2.9161;
CPm=55.6192;
Miupx=6.0679;
YPX=20.7502;
KPS=0.0017;
Kpi=63.9593;
KPI=72.5525;
KP=19.1078;
Miusx=1.8216;
YXS=2.6872;
YPS=60.3616;
[t,C]=ode23(@(t,C)ParameterZhang(t,C,Miumax,Ks,Kxi,KXI,CXm,CPm,Miupx,YPX,KPS,Kpi,KPI,KP,Miusx,YXS,YPS),Rentang,C0);
figure
yyaxis left
plot(t,C(:,[1 2]))
ylabel('Concentration (g/L)')
yyaxis right
plot(t, C(:,3))
ylabel('Concentration (\mu g/L')
grid
legend('C_1','C_2','C_3', 'Location','W')
end
function dCdt=ParameterZhang(t,C,Miumax,Ks,Kxi,KXI,CXm,CPm,Miupx,YPX,KPS,Kpi,KPI,KP,Miusx,YXS,YPS)
z = [1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20];
j = 1;
for j = 1 : 20
if z(j) <= 4
I = 45;
elseif z(j) <= 7
I = 90;
elseif z(j) <= 11
I = 120;
elseif z(j) <= 15
I = 150;
else
I = 180;
end
mu = ((Miumax*C(2))/(Ks+C(2)+(C(2)^2/Kxi)))*(I/(KXI+I))*(1-C(1)/CXm)*(1-C(3)/CPm);
dCdt(1,:) = mu*C(1);
dCdt(2,:) = (-(1/YXS)*dCdt(1))+(-(1/YPS)*dCdt(3))+(-Miusx*C(1));
dCdt(3,:) = (YPX*dCdt(1)+Miupx*C(1))*(C(2)/(KPS+C(2)+C(2)^2/Kpi))*(C(3)/(KP+C(3)))*(I/(KPI+I));
end
end
0 Kommentare
Akzeptierte Antwort
Star Strider
am 7 Nov. 2021
The problem is that in this assignment —
dCdt(2,:) = (-(1/YXS)*dCdt(1))+(-(1/YPS)*dCdt(3))+(-Miusx*C(1));
‘dCdt(3)’ has not yet been created, and only ‘dCdt(1)’ exists in the code at that point.
It will llikely be necessary to re-code the differential equations.
Also, ‘I’ is not a function of anything useful in the original code. I created an anonymous function to calculate it correctly as a function of ‘t’ rather than ‘j’ that does not otherwise exist in the code.
CobaParameterZhang
function CobaParameterZhang
Rentang = linspace(0, 20, 50);
C0 = [0.143; 0.9659; 0.094406];
Miumax=0.5258;
Ks=0.0211;
Kxi=56.6813;
KXI=53.26;
CXm=2.9161;
CPm=55.6192;
Miupx=6.0679;
YPX=20.7502;
KPS=0.0017;
Kpi=63.9593;
KPI=72.5525;
KP=19.1078;
Miusx=1.8216;
YXS=2.6872;
YPS=60.3616;
[t,C]=ode23(@(t,C)ParameterZhang(t,C,Miumax,Ks,Kxi,KXI,CXm,CPm,Miupx,YPX,KPS,Kpi,KPI,KP,Miusx,YXS,YPS),Rentang,C0);
figure
yyaxis left
plot(t,C(:,[1 2]))
ylabel('Concentration (g/L)')
yyaxis right
plot(t, C(:,3))
ylabel('Concentration (\mu g/L')
grid
legend('C_1','C_2','C_3', 'Location','W')
% end
function dCdt=ParameterZhang(t,C,Miumax,Ks,Kxi,KXI,CXm,CPm,Miupx,YPX,KPS,Kpi,KPI,KP,Miusx,YXS,YPS)
I = @(t) (45).*((t>=0)&(t<4)) + (90).*((t>=4)&(t<7)) + (120).*((t>=7)&(t<11)) + (150).*((t>=11)&(t<15)) + (180).*(t>=15);
mu = ((Miumax*C(2))/(Ks+C(2)+(C(2)^2/Kxi)))*(I(t)/(KXI+I(t)))*(1-C(1)/CXm)*(1-C(3)/CPm);
dCdt(1,:) = mu*C(1);
dCdt(2,:) = (-(1/YXS)*dCdt(1))+(-(1/YPS)*dCdt(3))+(-Miusx*C(1));
dCdt(3,:) = (YPX*dCdt(1)+Miupx*C(1))*(C(2)/(KPS+C(2)+C(2)^2/Kpi))*(C(3)/(KP+C(3)))*(I(t)/(KPI+I(t)));
end
end
Also, I have seen this before, and very recently, posted by a different person!
.
2 Kommentare
Star Strider
am 8 Nov. 2021
As always, my pleasure!
You are not bothering me! I apologise if I gave you that impression.
I am simply suggesting that the code for the differential equations needs a bit of work to get it running correctly, and I described the problem.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Numerical Integration and Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!