still having troubles with the way Matlab works...
I set up a model comprised of differential equations, which are called by the ode45 solver. The ode45 solver itself passes a function of v0 to the system.
This is my model:
%chemostat model, based on:
%DCc=-v0*Cc/V + umax*Cs*Cc/(Ks+Cs)-rd -->Change of cell concentration over time
%Dcs=(v0/V)*(Cs0-Cs) - Cc*(Ys*umax*Cs/(Ks+Cs)-m) -->Change of substrate concentration over time
function dydt=sys(t,y,v0,V,umax,Ks,rd,Cs0,Ys,m)
dydt=[-(v0(t,y)/V)*y(1)+(umax*y(1)*y(2))/(Ks+y(2))-rd;
(v0(t,y)/V)*(Cs0-y(2))-(Ys*umax*y(2)*y(1))/(Ks+y(2))];
This is my function of v0: `
function v0 = funV0( t,y )
persistent i
if isempty(i)
i=0;
end
if y(1) > 5 || i==1
v0=20
v0 = 20+200*t % As an example, if [Y1] > 5, then set v0 = [Y2]
i=1
else
v0=0
i=0
end
end
The model works fine if I just pass:
v0=20
v0=v0+200*t
However, the above code with the if conditions does not work. Even though y(1) initially is 1 (and increases slowly over time) the if condition is ignored.
Can somebody explain this behavior and maybe point out a solution?
Thanks in advance and special thanks again to Rollen D'Souza who helped me with the code in the first place.
Aucun commentaire:
Enregistrer un commentaire