Lotka volterra model for 3 species (1 prey - 2 predators)

22 views (last 30 days)
How can i adapt the following code and function to solve a three species lotka volterra model?
clc
clear clc
t0 = 0; %Condiciones iniciales.
tfinal = 15; %Condiciones finales.
y0 = [60.28; 2.043051]; %Poblaciones iniciales de depredadores y presas.
[t,y] = ode45(@lotka,[t0 tfinal],y0); %%Resuelve la ecuación de Lotka-Volterra
% con los parámetros anteriores gracias a la función "ode45 “ – (Fórmula Runge-Kutta (4,5)).
%Primer Gráfica.
nexttile % Graficar en una sola ventana.
plot(t,y) % Graficar función Lotka-Volterra.
title('Poblaciones de depredadores y presas a lo largo del tiempo')
xlabel('Tiempo t')
ylabel('Población')
legend('Presa','Depredador','Location','North')
%Segunda Gráfica.
nexttile % Graficar en una sola ventana.
plot(y(:,1),y(:,2))
title('Retrato de fase')
xlabel('Población Presa')
ylabel('Población Depredador')
function yp = lotka(t,y)
%LOTKA Lotka-Volterra predator-prey model.
yp = diag([1 - .01*y(2), -1 + .02*y(1)])*y;

Answers (1)

Sam Chak
Sam Chak on 24 Nov 2023
This isn't strictly a MATLAB-related question, but I believe animal behaviorists might be able to advise you. Alternatively, from a critical thinking perspective, you could consider modifying the Lotka-Volterra equations for a 2-predator-1-prey model.
In a particular phase, the prey population attains a level of abundance that initiates the growth of the predator communities. Over time, the heightened presence of predators induces a decline in the prey population. Subsequently, this reduction in prey numbers contributes to a decrease in the populations of the predators. Eventually, this cyclical pattern recurs.
tspan = [0 20];
y0 = [5; 3; 2];
[t, y] = ode45(@lotka, tspan, y0);
plot(t, y), grid on, ylim([0 6])
legend('Prey', 'Predator 1', 'Predator 2', 'location', 'SE')
xlabel('t')
title('Numbers of prey & predators for the Lotka-Volterra model')
%% Modified Lotka-Volterra 2-predator-1-prey model
function dydt = lotka(t, y)
dydt = zeros(3, 1);
% Parameters
a = 2.4; % maximum prey per capita growth rate
b1 = 0.6; % effect of the presence of predator 1 on the prey's growth rate
b2 = 0.6; % effect of the presence of predator 2 on the prey's growth rate
c1 = 0.8; % predator 1 per capita death rate
c2 = 0.8; % predator 2 per capita death rate
d1 = 0.3; % effect of the presence of preys on the predator 1's growth rate
d2 = 0.3; % effect of the presence of preys on the predator 2's growth rate
% Lotka-Volterra equations for 2 predators and 1 prey
dydt(1) = a*y(1) - b1*y(1)*y(2) - b2*y(1)*y(3); % Prey
dydt(2) = - c1*y(2) + d1*y(1)*y(2); % Predator 1
dydt(3) = - c2*y(3) + d2*y(1)*y(3); % Predator 2
end

Categories

Find more on Interpolation in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!