function [t, n, c] = chemostat(initConds)
tspan = [0; 80];
u0=initConds;
[t,u] = ode15s(@f,tspan,u0);
for j = 1:length(t)
n(j,1) = u(j,1);
c(j,1) = u(j,2);
end
function dudt = f(t,u)
a1 = 2;
a2 = 2;
dudt = [a1*u(2)/(1+u(2))*u(1) - u(1); -u(2)/(1+u(2))*u(1)-u(2)+a2];
n1 = 0.1;
c1 = 0.1;
p1 = [n1,c1];
[t1a, n1a, c1a] = chemostat(p1);
n2 = 0.5;
c2 = 10;
p2 = [n2,c2];
[t2a, n2a, c2a] = chemostat(p2);
n3 = 2;
c3 = 5;
p3 = [n3,c3];
[t3a, n3a, c3a] = chemostat(p3);
n4 = 1.25;
c4 = 0.5;
p4 = [n4,c4];
[t4a, n4a, c4a] = chemostat(p4);
figure
subplot(2,2,1)
plot(t1a,n1a,t1a,c1a)
title('Initial Conditions (n,c) = (0.1,0.1)')
subplot(2,2,2)
plot(t2a,n2a,t2a,c2a)
title('Initial Conditions (n,c) = (0.5,10)')
subplot(2,2,3)
plot(t3a,n3a,t3a,c3a)
title('Initial Conditions (n,c) = (2,5)')
subplot(2,2,4)
plot(t4a,n4a,t4a,c4a)
title('Initial Conditions (n,c) = (1.25,0.5)')
0 Comments
Sign in to comment.