Lotka volterra phase portrait MATLAB
36 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Réponses (1)
Mahdiar Sadeghi
le 6 Fév 2018
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 commentaires
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!