function n = pp_time(r1,K,n01,c,a,Th,d,n02,nostep)
%This is a function simulating predator-prey dynamics

%Prey:
%r1 - intrinsic growth rate 
%K - prey carrying capacity
%n01 - initial population sizes 

%Predator:
%c - prey conversion rate
%a - encounter rate
%Th - handling time
%d - predator mortality
%n02 - initial population size

%nostep - number of steps for simulation

temp1 = [n01];
temp2 = [n02];
  for t=1:nostep
     nprime1 = temp1(t) + r1*temp1(t)*(K-temp1(t))/K - temp2(t)*(a*temp1(t)^2/(1+a*Th*temp1(t)^2)) ;
     nprime2 = temp2(t) + c*temp2(t)*(a*temp1(t)^2/(1+a*Th*temp1(t)^2)) - d*temp2(t);
     if nprime1 < 0
        nprime1 = 0;
     end
     if nprime2 < 0
        nprime2 = 0;
     end
     temp1 = [temp1 nprime1];
     temp2 = [temp2 nprime2];
  end
n = [temp1;temp2];