% % laglogbif.m - this MATLAB file simulates the % lagged logistic difference equation % u(n+1)=a u(n) (1-u(n-1)) % as a system of 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)) % and carries out a bifurcation analysis by varying a. % 200 different values of a are used between the % ranges amin and amax set by the user. A bifurcation % plot is drawn by showing the last 250 points of % a sequence of 1000 simulated points for each % value of a. The initial conditions are % fixed at x0=.1 and y0=.2 s=1; while s>0; amin=input('input amin= lower intrinsic growth rate: ') amax=input('input amax= upper intrinsic growth rate: ') x0=.2; y0=.2; n=1000; jmax=200; t=zeros(jmax+1,1); z=zeros(jmax+1,250); del=(amax-amin)/jmax; for j=1:jmax+1 x=zeros(n+1,1); y=zeros(n+1,1); x(1)=x0; y(1)=y0; t(j)=(j-1)*del+amin; a=t(j); for i=1:n x(i+1)=y(i); y(i+1)=a*y(i)*(1-x(i)); if (i>750) z(j,i-750)=y(i+1); end end end plot(t,z,'k.') title('bifurcation plot'),pause s=input('Do you want to stop - if so enter 0') end