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 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