How do I run an ODE on a function with multiple variables?

조회 수: 6 (최근 30일)
Waleed
Waleed 2022년 11월 12일
댓글: Stephen23 2022년 11월 12일
I hope I am asking this question in the right place but I would kindly appreciate any help you can send my way. I am running this function
which works completely fine, however when I call an ODE45 on it to help me get less broad data, I keep getting an error of not having enough input arguments.
ode45(eliminationODE,[1 100], [0.4,0.016,dpop,1,1,0.1,tpop,0,0.16,1,1,0.5,0.4])
Not enough input arguments.
Error in eliminationODE (line 2)
dxdt=[ALPHAd + Rd.*Dt.*((Kd-BETAdd.*Dt-BETAdt.*Tt)/Kd); ALPHAt + Rt.*Tt.*((Kt-BETAtt.*Tt-BETAtd.*Dt)/Kt)-Tt.*GAMMAd.*Dt];
I am a bit confused as I am giving it the same amount of input arguments I do when I run the actual function. I even tried adding up to 5 random values but it still comes up as too few input arguments. Am I making a mistake in how I am running the ODE?
  댓글 수: 1
Stephen23
Stephen23 2022년 11월 12일
"Am I making a mistake in how I am running the ODE?"
Yes. You are calling the function (rather than providing ODE45 with a function handle as it requires):
ode45(eliminationODE,..)
% ^^^^^^^^^^^^^^ this calls your function
Note that the specification given in the ODE45 documentation requires that the function must accept "..a scalar t and a column vector y", whereas your function requires lots and lots of separate input arguments. To follow the documentation you should modify your function to accept the specified two input arguments. If you need to pass further parameters then also read:

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

답변 (1개)

Torsten
Torsten 2022년 11월 12일
[T,Y] = ode45(@(t,y)eliminationODE(y(1),y(2),y(3),y(4),y(5),y(6),y(7),y(8),y(9),y(10),y(11),y(12),y(13)),[1 100], [0.4,0.016,dpop,1,1,0.1,tpop,0,0.16,1,1,0.5,0.4])
instead of
ode45(eliminationODE,[1 100], [0.4,0.016,dpop,1,1,0.1,tpop,0,0.16,1,1,0.5,0.4])

카테고리

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

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by