How to represent the followind ODE system in MatLab?

1 visualización (últimos 30 días)
Cristian Gav
Cristian Gav el 21 de Jun. de 2019
Comentada: Star Strider el 21 de Jun. de 2019

Respuesta aceptada

Star Strider
Star Strider el 21 de Jun. de 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 comentarios
Cristian Gav
Cristian Gav el 21 de Jun. de 2019
It's for a work project .Feel free to post the solution if you can.
Star Strider
Star Strider el 21 de Jun. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by