%Purpose: simulation of a predator-prey system
%Author: Jie Zhang
%Date:   Oct. 31, 2013
%Comments: this is for the CDS130 class

clear        %clear the work space
clc;         %clear the command window for diaplaying the output

%
%setting up the parameters for the model
%
R(1)=100.0   %initial population of rabbits
F(1)=20.0    %initial population of foxs
BR_rabbit=0.5     %birth rate of rabbit 
DR_rabbit_INT=0.02   %death date of rabbit (prey) due to interaction
DR_fox=0.10     %death rate of fox
BR_fox_INT= 0.001 % birth rate of fox (predator) due to interaction

%
%calculation based on the model requirements
%
for i=1:50
 R(i+1)=R(i)+BR_rabbit*R(i)-DR_rabbit_INT*R(i)*F(i)
 F(i+1)=F(i)-DR_fox*F(i)+BR_fox_INT*F(i)*R(i)
end

%
%---- plotting section ---%
%
hold off %clear the previous plot setting
figure(1)  %make plot 1 for rabbit population evolution
plot(R,'-*r')    %line specification: solid line, marker *, red color  
hold all  %hold on all previous settings: plotting window, axis, styles
plot(F,':ob')    %line specification: dotted line, marker circle, blue

%
%proper annotation of the plots
%
legend('Rabbit','Fox')   %add legend to the plots
xlabel('Year')    % X axis label
ylabel('Population Numbers')   % Y axis label
title('Predator-prey Model Result',...
    'FontSize',18)
