not enough input argument error

3 vues (au cours des 30 derniers jours)
aubelee
aubelee le 21 Avr 2021
Commenté : Stephan le 21 Avr 2021
I am trying to run this code, however, it seems that it's giving me a not enough input error (Not enough input arguments.
Error in repressilator (line 7), m1 = -y(1) + alpha/(1+y(6)^n) + alpha0;). Could someone please help me to run this?
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')

Réponse acceptée

Stephan
Stephan le 21 Avr 2021
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')
function ydot=repressilator(~,y)
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];
end
  2 commentaires
aubelee
aubelee le 21 Avr 2021
it gives me :>> repressilator(y, p)
Unrecognized function or variable 'y'.
Stephan
Stephan le 21 Avr 2021
See my edited answer - the code works

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by