Lotka volterra phase portrait MATLAB
조회 수: 35 (최근 30일)
이전 댓글 표시
I'm confused by the quiver and ode45 functions used to plot phase portraits. I want you use MATLAB to plot the isoclines and closed phase plane trajectories to model the predator-prey Lotka-Volterra system of equations:
dx/dt=alpha * x - beta * x * y
dy/dt=delta * x * y - gamma * y
Thank you.
댓글 수: 1
답변 (1개)
Mahdiar Sadeghi
2018년 2월 6일
Note that ode45 is gives the solution of Ordinary Differential Equations (ODE) over time with respect to its initial condition. While quiver displays velocity vectors as arrows with components (u,v) at the points (x,y). So one way of using MATLAB to plot phase portrait of the predator-prey Lotka-Volterra system can be (for the case α=β=δ=γ=1):
%specify the region of the plot for vector plot
[x1, x2] = meshgrid(-1:0.2:3, -1:.2:3);
x1dot = x1 - x2 .*x1; %Note the use of .* and .^
x2dot = x1 .* x2 - x2;
%first plot the vector plot with quiver
figure
quiver(x1,x2,x1dot, x2dot)
% predator-prey Lotka-Volterra system
f = @(t,y) [y(1) - y(1)*y(2); y(1)*y(2) - y(2)];
hold on
%calculate the phase trajectories for different initial conditions
for y0=0:.7:2.8
[ts, ys] = ode45(f,[0, 8], [y0/2, y0]);
% plot of closed loop phase trajectories
plot(ys(:,1), ys(:,2))
end
hold off
xlabel('x')
ylabel('y')
댓글 수: 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!