How to represent the followind ODE system in MatLab?

1 次查看(过去 30 天)

采纳的回答

Star Strider
Star Strider 2019-6-21
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 个评论
Cristian Gav
Cristian Gav 2019-6-21
It's for a work project .Feel free to post the solution if you can.
Star Strider
Star Strider 2019-6-21
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by