필터 지우기
필터 지우기

Phase Portrait of ODE system

조회 수: 39 (최근 30일)
Jiwon Park
Jiwon Park 2022년 5월 15일
답변: Steven Lord 2022년 5월 15일
I need to generat the phase portrait of the ode system given, where r,p,c and b are given constants
dv/dt=rv-pvx
dx/dt=cv-bx
Below matlab code is what I have gotten so far
However, how do I implement ode45 functione here?
I would like to use ode45 function, but was not sure how to do so.
If some one could guide me through how to use ode45 function to generate the phase portrait, it will be much appreciated.
% Part IIa. Base Case
% Phase Portrait
clc
clear
close all
%
%
r=2.5;
p=2;
c=0.1;
b=0.1;
%
[x,v]=meshgrid(0:1:5, 0:1:5);
dx=r.*v-p.*v.*x;
dv=c.*v-b.*x;
streamslice(x,v,dx,dv,'filled');
quiver(x,v,dx,dv);

답변 (2개)

Alan Stevens
Alan Stevens 2022년 5월 15일
Do you mean something like this:
% Part IIa. Base Case
% Phase Portrait
%
%
r=2.5;
p=2;
c=0.1;
b=0.1;
%
% [x,v]=meshgrid(0:1:5, 0:1:5);
% dx=r.*v-p.*v.*x;
% dv=c.*v-b.*x;
% streamslice(x,v,dx,dv,'filled');
% quiver(x,v,dx,dv);
% Set time interval as you desire (arbitrary values used here)
tspan = [0 50];
% Set initial conditions as you desire (arbitrary values used here)
X0 = [0.2 0]; % [x0 v0]
[t, X] = ode45(@(t,X) rate(t,X,r,p,c,b),tspan,X0);
x = X(:,1); v = X(:,2);
plot(x,v),grid
xlabel('x'),ylabel('y')
function dXdt = rate(~,X,r,p,c,b)
x = X(1); v = X(2);
dXdt = [r*v-p*v*x;
c*v-b*x];
end

Steven Lord
Steven Lord 2022년 5월 15일
You could use ode45 with the 'OutputFcn' option set to @odephas2 using odeset, as shown in this Answers post.

카테고리

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