필터 지우기
필터 지우기

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

조회 수: 14 (최근 30일)
José Manuel
José Manuel 2023년 11월 23일
편집: José Manuel 2023년 11월 27일
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;

답변 (1개)

Sam Chak
Sam Chak 2023년 11월 24일
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

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by