How to represent the followind ODE system in MatLab?

1 回表示 (過去 30 日間)
Cristian Gav
Cristian Gav 2019 年 6 月 21 日
コメント済み: Star Strider 2019 年 6 月 21 日

採用された回答

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 Center および File ExchangeOrdinary Differential Equations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by