how to solve the below error
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Undefined function or variable 'm1'.
Error in repressilator (line 7) y = [m1 p1 m2 p2 m3 p3];
in matlab program 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]; 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')
0 Commenti
Risposta accettata
Torsten
il 18 Giu 2018
function main
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')
end
function ydot=repressilator(t,y)
alpha0 = 1;
n = 2.0;
beta = 5;
alpha = 1000;
% order of species;
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];
end
Più risposte (1)
Ankita Bansal
il 18 Giu 2018
You have written ODEFUN=@repressilatorddt; but you have not defined repressilatorddt.
You can modify your code to
function repressilatorr
clear all
%declare model parameters
global alpha
global alpha0
global n
global beta
%assign parameter values
alpha0=60*(5e-4); %transcripts/sec
alpha=60*(5-alpha0); %transcripts/sec
n=2;
beta=1/5;
%set simulation parameters
Tend=1000
ODEFUN=@repressilatorddt;
options=odeset('Refine', 6);
%set initial condition: state = [m1 p1 m2 p2 m3 p3]
x0=[0.2 0.1, 0.3 0.1 0.4 0.5]';
%run simulation
[t,s]=ode45(ODEFUN, [0,Tend], x0, options);
%produce figure 7.21A
figure(1)
set(gca,'fontsize',14)
t=t/0.3485
plot(t,40*s(:,2), 'k',t,40*s(:,4), 'k--', t,40*s(:,6), 'k:','Linewidth', 3)
axis([0 800 0 7000])
ylabel('protein abundance (molecules per cell)')
xlabel('Time (min)')
legend('Protein 1', 'Protein 2', 'Protein 3')
end
function dS=repressilatorddt(t,s)
global alpha
global alpha0
global n
global beta
m1=s(1);
p1=s(2);
m2=s(3);
p2=s(4);
m3=s(5);
p3=s(6);
m1ddt= alpha0 + alpha/(1+p3^n) - m1;
p1ddt=beta*(m1-p1);
m2ddt= alpha0 + alpha/(1+p1^n) - m2;
p2ddt=beta*(m2-p2);
m3ddt= alpha0 + alpha/(1+p2^n) - m3;
p3ddt=beta*(m3-p3);
dS =[m1ddt, p1ddt, m2ddt, p2ddt, m3ddt, p3ddt]';
end
Vedere anche
Categorie
Scopri di più su Genomics and Next Generation Sequencing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!