Discrete model of population dynamics with competition (Matlab)

228 Views Asked by At

I am trying to create a model considering a lake in which two species coexist, interacting with each other, performing intra- and inter-specific competitions, disputing the same sources of nutrition. Considering also the release of pollutant in this lake, a pollutant that negatively affects the two populations, and initially considered a consumption of pollutants by the two populations.

But it results in a graph that would necessarily have to have a curve, which does not happen and I'm not sure if I programmed the equations correctly. Could someone please help me?

clc
clear all

% Species A 
a = 0.5; % Bird
b = 0.1; % pollution bite
c = 0.05; % Intraspecific competition
d = 0.06; % intrspecific competition

% Species B 
e = 0.4; % Natalidade 
f = 0.09; % pollution bite
g = 0.04; %  Intraspecific competition
h = 0.05; %  intrspecific competition

% Initial population of species
A(1) = 100;
B(1) = 150;

t = 0:365;

for n = 1:365
     A(n+1) = a*A(n) - b*A(n)-c*A(n)^2 - d*B(n)*A(n);
     B(n+1) = e*B(n) - f*B(n)-g*B(n)^2 - h*A(n)*B(n);    
 end

 hold on 
 plot(t,A,'-y','LineWidth',2,'MarkerEdgeColor','k',...
        'MarkerFaceColor','k',...
        'MarkerSize',1) 

 hold on 
 plot(t,B,'-m','LineWidth',2,'MarkerEdgeColor','k',...
        'MarkerFaceColor','k',...
        'MarkerSize',1)


legend('Species A','Species B')            
grid on
title('Species Dynamics over Time', 'fontsize', 18)
xlabel('temp (days)', 'fontsize', 15);
ylabel('Species Dynamics', 'fontsize', 15);
axis([0, 365, 0, 150]);

The equation is:

$dA/dt = aA-bA - cA^2-dBA$

$dB/dt = eB-fB - gB^2-hAB$

Sorry, can not put the generated image!

1

There are 1 best solutions below

3
On

You might want to rethink how you input the equations. If you use a backward difference scheme to approximate the derivative your equation should look like: $A(t_n)-A(t_{n-1})=(t_n-t_{n-1})\cdot f(A(t_n),B(t_n))$. It looks like in your code, you forgot about the time step and the value of the function at the previous time step. You could also use a different scheme and get something similar.