How to represent the followind ODE system in MatLab?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Réponse acceptée
Star Strider
le 21 Juin 2019
Define ‘y’ as ‘x(1)’, ‘k’ as ‘x(2)’, and code it using those substitutions. (I coded it as a one-line anonymous function.)
Remember to include ‘a’ in the argument list, then pass a value for ‘a’ to it in your ODE solver call. See Passing Extra Parameters.
If this is not homework, I can post my solution.
2 commentaires
Star Strider
le 21 Juin 2019
Since it’s not homework, sure!
% % % x(1) = y, x(2) = k
ODEfcn = @(t,x,a) [0.25*x(1).*(1-x(1)) - 0.0015*x(2) - 0.3*x(1); 0.25*x(1).*(1-x(1)) - 0.0515*x(2)];
ic = [1 1];
tspan = [0 50];
a = 42; % Substitute Correct Value
[t,y] = ode45(@(t,x)ODEfcn(t,x,a), tspan, ic);
figure
plot(t, y)
grid
It is always appropriate to check it to be certain I transcribed it correctly. Use the appropriate initial conditions (‘ic’) and time interval or vector (‘tspan’). See the documentation for the various functions and for Anonymous Functions for a full explanation.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations 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!