clc
close all
clear all

%Program to simulate the repressilator

%parameters in a structure
struct.V1=1;
struct.K1=1;
struct.n1=1;
struct.V2=struct.V1;
struct.K2=struct.K1;
struct.n2=struct.n1;
struct.V3=struct.V1;
struct.K3=struct.K1;
struct.n3=struct.n1;

%set tspan
tStart=0;
tEnd=100;

%call ode45 to solve the system of differential equations
%first gene is x1 (initial condition = 0)
%second gene is x2 (initial condition = 0)
%third gene is x3 (initial condition = 1)
%set the options for ode45
optionsODE=odeset('AbsTol',[1e-5 1e-5 1e-5],'RelTol',1e-4);
[T Y]=ode45('repressilator',[tStart tEnd],[1 0 0],optionsODE,struct);

x1=Y(:,1);
x2=Y(:,2);
x3=Y(:,3);

%plot the gene profiles
figure(1)
plot(T,x1,'-b',T,x2,'-r',T,x3,'-g');
xlabel('time');
ylabel('expression level');
legend('x1','x2','x3');