%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % solves the Predator-prey equations % % % % x' = ...you choose... % % y' = ...you choose % % % % requires the use of file: odeplay.m % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear; global r; global a; global b; global k; r = .1; a = .1; b = .1; k = .5; % time span of integration tspan = [0 10]; % initial conditions x0 = 100; y0 = 10; v0 = [x0,y0]; % solves ode using ode45 routine [t,vout] = ode45(@odeplay,tspan,v0); % % plots y(t) for xstar=0.0 in an upper subplot % % note: %%paramstring = sprintf( ', {\\itb}=%d, {\\itc}=%d,{\\itx_0}=%d', b, c, xstar); figure(1) clf subplot(2,1,1) plot( t, vout(:,1) ); xlabel( '{\itt}' ); ylabel( '{\itx}({\itt})' ); title('Prey') axis tight; grid on; subplot(2,1,2) plot( t, vout(:,2) ); xlabel( '{\itt}' ); ylabel( '{\ity}({\itt})' ); title( 'Predator') axis tight; grid on;