Phase Portrait of ODE system
31 ビュー (過去 30 日間)
古いコメントを表示
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);
0 件のコメント
回答 (2 件)
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
0 件のコメント
Steven Lord
2022 年 5 月 15 日
You could use ode45 with the 'OutputFcn' option set to @odephas2 using odeset, as shown in this Answers post.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!