% % laglogis.m - this MATLAB file simulates the % lagged logistic difference equation % u(n+1)=a u(n) (1-u(n-1)) % as a system pof two first order equations: % letting x(n) = u(n-1) % y(n) = u(n) % giving % x(n+1) = y(n) % y(n+1) = a*y(n)*(1-x(n)) % The user is prompted to read in the value % of x0 and y0, the paramters a % and the time interval over which to run the % simulation. s=1; while s>0; a=input('input a=intrinsic growth rate: ') x0=input('input initial population at time 0: ') y0=input('input initial population at time 1: ') n=input('input time period of run: ') x=zeros(n+1,1); y=zeros(n+1,1); t=zeros(n+1,1); equilibrium=(a-1)/a x(1)=x0; y(1)=y0; for i=1:n t(i)=i-1; x(i+1)=y(i); y(i+1)=a*y(i)*(1-x(i)); end t(n+1)=n; plot(t,x,t,x,'o') title('time series'),pause plot(x,y,x,y,'o') title('semi-orbit'),pause plot(x,y,'o') title('semi-orbit not connected'),pause s=input('Do you want to stop - if so enter 0') end