% --------------------
% Predator-Prey model
% use with foxrabbit.m
% --------------------
clear all ;clf;%, close all;
global a b c d w w1 w2 % set parameters visible to all program parts 
a=0.05;  % rabbit birth rate 
b=0.001; % rabbit death rate
c=0.0001; % fox    birth rate
d=0.01;   % fox    death rate
% climate factors
w=100; w1=0.3;w2=0.2;
% initial parameters
t0=0; tx=1000; % time limits
Ntot=100; % total population
rabbits = 60; foxes = Ntot - rabbits; % init. populations
% ODE options
options = odeset('RelTol',1e-3,'AbsTol',[1e-5 1e-5]);
% solve the diff. equations 
[time,pop] = ode45(@foxrabbit,[t0 tx],[rabbits foxes],options);
% output
figure(1)
plot(time,pop(:,1),'b',time,pop(:,2),'r--');hold on;
legend('rabbit','fox')
title('Predator-Prey model')
%
% comments: there are a few unnatural things happening like
%           a 1 (or even 0) rabbits happily gives birth to 
%           more rabbits...
%          