not enough input argument error

2 Ansichten (letzte 30 Tage)
aubelee
aubelee am 21 Apr. 2021
Kommentiert: Stephan am 21 Apr. 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')

Akzeptierte Antwort

Stephan
Stephan am 21 Apr. 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 Kommentare
aubelee
aubelee am 21 Apr. 2021
it gives me :>> repressilator(y, p)
Unrecognized function or variable 'y'.
Stephan
Stephan am 21 Apr. 2021
See my edited answer - the code works

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by