% % spec2eq.m - this MATLAB file simulates the % 2-species difference equation: % x(n+1) = x(n) (1 - y(n)) % y(n+1) = y(n) (x(n) -1) % which has a line of equilibria (K,0) for any K. % The user is prompted to read in the value % of x0 and y0 which must be in (0,1) % and the time interval over which to run the % simulation. !c: s=1; while s>0; x0=input('input initial population x0: ') y0=input('input initial population x0: ') n=input('end of time interval b: ') x=zeros(n+1,1); y=zeros(n+1,1); t=zeros(n+1,1); x(1)=x0; y(1)=y0; for i=1:n t(i)=i-1; x(i+1)=x(i)*(1-y(i)); y(i+1)=y(i)*(x(i)-1); end t(n+1)=n; plot(t,x,t,x,'o') title('x values'),pause plot(t,y,t,y,'o') title('y values'),pause s=input('Do you want to stop - if so enter 0') end