% predprey.m - predator prey model for CDS 101/110
% RMM, Oct 07 (following notes from L. Soto)
%
% This file contains a simple model for a predator prey system. The
% model is developed following the treatment in the book by Murray
% (the other one).
%
% The states for these equations are
%
% x(1) # of rabbits (prey)
% x(2) # of foxes (predator)
%
% The equations allow for a quadratic term in both the predator and
% prey species that cause the population to fall off if you get too
% many of a given species. These terms are turned off by default.
%
function dxdt=predprey(t, x, flags, r, d, b, k, a, c)
% Extract the states
x1 = x(1);
x2 = x(2);
% Set up the parameter values [these should be passed as arguments...]
if (nargin < 4) r = 1.6; end;
if (nargin < 5) d = 0.56; end;
if (nargin < 6) b = 0.6; end;
if (nargin < 7) k = 125; end;
if (nargin < 8) a = 3.2; end;
if (nargin < 9) c = 50; end;
dx1 = r * x1 * (1 - x1/k) - a * x2 * x1/(c + x1);
dx2 = b *a *x2 * x1 / (c + x1) - d * x2;
dxdt = [dx1; dx2];