% % log2cyl.m - This MATLAB file illustrates the 2 point cycle % possibilities of the discrete logistic map % x(i+1)=r*x(i)*(1-x(i)) % by graphing the composition of the logistic with % itself, and drawing the 45 degree line % The user is prompted to read in the value % of r to use and the graph is plotted from x =0 to 1 !c: s=1; n=100; while s>0; r=input('input growth rate r: ') del=1./n; xstart=0; y=zeros(n+1,1); lin=zeros(n+1,1); x=zeros(n+1,1); for i=1:n+1 x(i)=xstart+(i-1)*del; lin(i)=x(i); y(i)=r*(r*x(i)*(1-x(i)))*(1-r*x(i)*(1-x(i))); end plot(x,lin,x,y) title('graph and y=x'),pause s=input('Do you want to stop - if so enter 0') end