0% found this document useful (0 votes)
170 views

Matlab Code PP Model Rk-4

This Matlab code implements a numerical integration of the Lotka-Volterra predator-prey model to model the interaction between a krill population and a whale population over time. The code uses a second order Runge-Kutta method to model the changing populations at each time step based on intrinsic growth rates and effects of predation between the two species. The code generates plots of the phase plane and population levels over time to illustrate the oscillating predator-prey dynamics.

Uploaded by

Vibhanshu Verma
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
170 views

Matlab Code PP Model Rk-4

This Matlab code implements a numerical integration of the Lotka-Volterra predator-prey model to model the interaction between a krill population and a whale population over time. The code uses a second order Runge-Kutta method to model the changing populations at each time step based on intrinsic growth rates and effects of predation between the two species. The code generates plots of the phase plane and population levels over time to illustrate the oscillating predator-prey dynamics.

Uploaded by

Vibhanshu Verma
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Matlab code for Lotka-Volterra predator prey model.


%
% Pred_runge.m
%
% This program implements a numerical integration of the
% Lotka-Volterra predator-prey model using Second order Runge-Kutta.
% The form of this code is more matlab style than pred.m
%
% Author: L.G. de Pillis
% Date: January 1997
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a=1.0;
b=0.5;
c=0.75;
d=0.25;

% (a-bW) is the intrinsic growth rate of the krill


%
% (-c+dK) is the intrinsic growth rate of the whales
%

% Set initial conditions


tinit = 0.0;
% start time
tfinal = 50.0; % stop time
K1(1)=5.0;
% intial krill population
W1(1)=1.0;
% intial whale population
n = 2000;
% number of time steps
dt = (tfinal-tinit)/n; % time step size
T=[tinit:dt:tfinal]; % create vector of discrete solution times
% Execute second order RK
for i = 1:n
k1 =
K1(i) + 0.5*dt*K1(i)*(a-b*W1(i));
w1 =
W1(i) + 0.5*dt*W1(i)*(-c+d*K1(i));
K1(i+1) = K1(i) + dt*k1*(a-b*w1);
W1(i+1) = W1(i) + dt*w1*(-c+d*k1);
end;
%Plot Results...
S1 = sprintf('IC: W0=%g, K0=%g',W1(1),K1(1));
figure(1)
clg;
plot(K1,W1);
title('Phase Plane Plot');
xlabel('Krill');
ylabel('Whales');
legend(S1,0);
grid;
figure(2)
clg;
plot(T,K1,'r-',T,W1,'g-.');
legend('Krill','Whales');
xlabel('time');
ylabel('whales and krill');
title(S1)

You might also like