%
% nicholv2.m - this MATLAB file simulates the 
% 2-species Nicholson Bailey difference equation
% modified to include host density dependence:
%       x(n+1) = x(n)*exp(r*(1-x(n)/K)-a*y(n))
%       y(n+1) = x(n)*(1-exp(-a*y(n))) 
% The user is prompted to read in the value
% of x0 and y0, the paramters r, a, and K
% and the time interval over which to run the 
% simulation.
!c:
s=1;
while s>0;
r=input('input r=host repro rate:     ')
a=input('input a=search efficiency of parasitoid:     ')
K=input('input K=host carrying capacity:     ')
x0=input('input initial population x0 of host:     ')
y0=input('input initial population y0 of parasitoid:     ')
n=input('input time period of run:     ')
x=zeros(n+1,1);
y=zeros(n+1,1);
t=zeros(n+1,1);
x(1)=x0;
y(1)=y0;
for i=1:n
t(i)=i-1;
x(i+1)=x(i)*exp(r*(1-x(i)/K)-a*y(i));
y(i+1)=x(i)*(1-exp(-a*y(i)));
end
t(n+1)=n;
plot(t,x,t,x,'o')
title('host values'),pause
plot(t,y,t,y,'o')
title('parasitoid values'),pause
plot(x,y,'o')
title('host vs parasitoid'),pause
s=input('Do you want to stop - if so enter 0')
end

