function n = logist(r,k,n0,lag,nostep)
%simulates logistic growth with time lags

%r - intrinsic growth rate
%k - carrying capacity
%n0 - initial population size
%lag - time lag in steps
%nostep - number of steps for simulation

  n = [n0];
  for t=1:nostep
     if t<=lag
        nprime = n(t) + r*n(t)*(k-n(t))/k;
     else
        if (n(t) <= 0)
           nprime = 0;
        else
           nprime = n(t) + r*n(t-lag)*(k-n(t-lag))/k;
        end
     end
     if nprime < 0
        nprime = 0;
     end
    n =[n nprime];
  end