not enough input argument error

조회 수: 2 (최근 30일)
aubelee
aubelee 2021년 4월 21일
댓글: Stephan 2021년 4월 21일
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')

채택된 답변

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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by