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

6 vues (au cours des 30 derniers jours)
Waleed
Waleed le 12 Nov 2022
Commenté : Stephen23 le 12 Nov 2022
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 commentaire
Stephen23
Stephen23 le 12 Nov 2022
"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:

Connectez-vous pour commenter.

Réponses (1)

Torsten
Torsten le 12 Nov 2022
[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])

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by