function ydot=repressilator(t,y,p)
alpha0 = 1;
n = 2.0;
beta = 5;
alpha = 1000;
% order of species; y = [m1 p1 m2 p2 m3 p3]
m1 = -y(1) + alpha/(1+y(6)^n) + alpha0;
p1 = -beta*(y(2) - y(1));
m2 = -y(3) + alpha/(1+y(2)^n) + alpha0;
p2 = -beta*(y(4) - y(3));
m3 = -y(5) + alpha/(1+y(4)^n) + alpha0;
p3 = -beta*(y(6) - y(5));
ydot = [m1; p1; m2; p2; m3; p3];
This function returns the values of the six derivatives corresponding to the left hand side of Equations (1.9.1). Note that the parameters have been hard-coded into the function with the values timespan=[0 15];
y0 = [0 1 0 1 0 1];
[t,y] = ode45(@repressilator,timespan,y0);
figure()
plot(t,y)
xlabel('Time')
ylabel('Amount')
legend('m1','p1','m2','p2','m3','p3','Location','SouthEast')
figure()
plot(y(:,1), y(:,2))
xlabel('Amount m1')
ylabel('Amount p1')
The returned timespan=[0 15];
y0 = [0 1 0 2 0 5];
[t,y] = ode45(@repressilator,timespan,y0);
figure();
plot(t,y)
xlabel('Time')
ylabel('Amount')
legend('m1','p1','m2','p2','m3','p3','Location','NorthWest')
figure();
plot(y(:,1), y(:,2))
xlabel('Amount m1')
ylabel('Amount p1')
function ydot=repressilator2(t,y,p)
alpha0 = p(1);
n = p(2);
beta = p(3);
alpha = p(4);
% order of species; y = [m1 p1 m2 p2 m3 p3]
m1 = -y(1) + alpha/(1+y(6)^n) + alpha0;
p1 = -beta*(y(2) - y(1));
m2 = -y(3) + alpha/(1+y(2)^n) + alpha0;
p2 = -beta*(y(4) - y(3));
m3 = -y(5) + alpha/(1+y(4)^n) + alpha0;
p3 = -beta*(y(6) - y(5));
ydot = [m1; p1; m2; p2; m3; p3];
timespan=[0 15];
y0 = [0 1 0 2 0 3];
params1 = [1 1.75 5 5];
params2 = [1 1.75 5 28];
params3 = [1 1.75 5 1000];
[t1,y1] = ode45(@repressilator2,timespan,y0,[],params1);
[t2,y2] = ode45(@repressilator2,timespan,y0,[],params2);
[t3,y3] = ode45(@repressilator2,timespan,y0,[],params3);
figure();
subplot(3,1,1)
plot(t1,y1)
ylabel('Amount')
subplot(3,1,2)
plot(t2,y2)
ylabel('Amount')
subplot(3,1,3)
plot(t3,y3)
xlabel('Time')
ylabel('Amount')
figure();
subplot(3,1,1)
plot(y1(:,1), y1(:,2))
ylabel('Amount p1')
subplot(3,1,2)
plot(y2(:,1), y2(:,2))
ylabel('Amount p1')
subplot(3,1,3)
plot(y3(:,1), y3(:,2))
xlabel('Amount m1')
ylabel('Amount p1')
This code shows how we now pass the parameters into the ODE integration function. If you access the help information for