Generating Phase Portrait of ODE system

53 ビュー (過去 30 日間)
Jiwon Park
Jiwon Park 2022 年 5 月 15 日
回答済み: Steven Lord 2023 年 12 月 18 日
I need to generate the phase portrait of the system of ode below.
dv/dt=rv-pvx
dx/dt=cv-bx
Where the constants are given below
r=2.5
p=2
c=0.1
b=0.1
I was assuming to use ode45 function in matlab to solve the system first, but I was not sure how to do this.
Becasue the system above are 2 different variables( v and x), should I solve each ode seperately?
I guess I do not have a good understanding of ode here so would be much appreciated if someone could provide step by step guide to generate phase portrait here.

回答 (2 件)

Saarthak Gupta
Saarthak Gupta 2023 年 12 月 18 日
Hi Jiwon,
I understand that you wish to plot the phase portrait of a nonlinear system of ODEs.
For a nonlinear system of the form:
plotting the phase portrait is a straightforward task.
In a phase portrait, we plot the trajectories of the system in the phase plane. Trajectories follow the direction field. The direction of the trajectory is the direction of the velocity vector, defined as (f(x,y), g(x,y))
You may use the “quiver” function to plot arrows with directional components at each point in the phase plane to achieve the same.
Please refer to the following code:
x = -20:20;
y = -20:20;
[X,Y] = meshgrid(x,y);
r=2.5;
p=2;
c=0.1;
b=0.1;
% direction vectors
U = c*Y-b*X;
V = r*Y-p*X.*Y;
% plot phase portrait of the system
quiver(X,Y,U,V,2);
% plot x and y nullclines
hold on
plot(x, (b/c)*x, 'r--'); % plot y = (b/c)*x
plot(x, zeros(size(x)), 'g--'); % plot y = 0
plot(p/r+zeros(size(y)), y, 'g--'); % plot x = p/r
hold off
legend("", "X nullcline", "Y nullcline");
The code also plots X and Y nullclines of the system for comparison.
Please refer to the following MATLAB documentation for further reference:
Hope this helps!
Best regards,
Saarthak

Steven Lord
Steven Lord 2023 年 12 月 18 日
I would specify an OutputFcn in your call to the ODE solver, as described on this documentation page for the odeset function. The odephas2 or odephas3 functions included in MATLAB may be of interest to you.

カテゴリ

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