% % code12Wb.m -- 20 nov 02 -- djm % % - single population code clear global ODE r1 a1 r2 a2 s1 s2 % set ODE choice disp(' ') disp(' ODE choices:') disp(' 1) two limited populations') disp(' 2) grass & cattle') disp(' 3) grass & hungry cattle') disp(' 4) example 2, page 495') disp(' ') setup = input('choose 1/2/3/4/R: '); disp(' ') disp(' click to choose IV (bottom to quit)') disp(' ') switch setup case{1} ODE = 1; r1 = 1; a1 = 0.5; r2 = 1; a2 = 0.5; s1 = 0; s2 = 0; case{2} ODE = 1; r1 = 1; a1 = 0.5; r2 = 1; a2 = 0.5; s1 = 0.2; s2 = 0; case{3} ODE = 1; r1 = 1; a1 = 0.5; r2 = 1; a2 = 0.5; s1 = 1.2; s2 = 0; case{4} ODE = 2; r1 = 1; a1 = 1; r2 = 0.5; a2 = 0.25; s1 = 1; s2 = 0.75; otherwise break end figure(1); clf; hold on title('\bf population phase plane') xlabel('\bf y(t)-axis') ylabel('\bf z(t)-axis') axis([0 4 0 4]) IV = []; while (isempty(IV)) click = ginput(1); IV = click; if(IV(2)<0) break end % invoke runge-kutta solver opt = odeset('RelTol',1e-3,'AbsTol',1e-6); [t y] = ode45(@Fode12Wb,[0 10],IV,opt); plot(y(:,1),y(:,2),'r') plot(IV(1),IV(2),'ko') IV = []; end