%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
% solves the Predator-prey equations            %
%                                               %
%   x' = ...you choose...                       %
%   y' = ...you choose                          %
%                                               % 
% requires the use of file:  odeplay.m          % 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% compute derivatives for damped pendulum, 
% from K Tung p. 227, b=omega^2, k= gamma, r=omega_D, a= D 

clear;

global r;
global a;
global b;
global k;


  r = 1.2;
  a = 4;
  b = 4;
  k = .05;

% time span of integration
  tspan = [0 100];
% initial conditions
x0 = 1;
y0 = 0;
z0 = 0; 
v0 = [x0,y0,z0];

% solves ode using ode45 routine

[t,vout] = ode45(@damppend,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('angle')
axis tight;
grid on;

subplot(2,1,2)

plot( t, vout(:,2) );
xlabel( '{\itt}' );
ylabel( '{\ity}({\itt})' );
title( 'angular velocity')
axis tight;
grid on;