function n = lv2_dist(r1,k1,n01,r2,k2,n02,alfa12,alfa21,frequ,int1,int2,nostep)
%This is a function simulating Lotka-Volterra dynamics with disturbance for two species

%r1, r2 - intrinsic growth rates for species 1 and 2
%k1, k2 - carrying capacities
%n01, n02 - initial population sizes
%alfa12, alfa21 - competition coefficients
%frequ - how often to disturb (no of time steps between disturbance events)
%int1, int2 - proportion of population of species 1 and 2 left after disturbance  
%nostep - number of steps for simulation


%Function body
temp1 = [n01];
temp2 = [n02];
  for t=1:nostep
     nprime1 = temp1(t) + r1*temp1(t)*(k1-temp1(t)-alfa12*temp2(t))/k1;
     nprime2 = temp2(t) + r2*temp2(t)*(k2-temp2(t)-alfa21*temp1(t))/k2;
     if nprime1 < 0
        nprime1 = 0;
     end
     if nprime2 < 0
        nprime2 = 0;
     end
     if mod(t,frequ) == 0
        nprime1 = nprime1*int1;
        nprime2 = nprime2*int2;
     end
     temp1 = [temp1 nprime1];
     temp2 = [temp2 nprime2];
  end
n = [temp1;temp2];