%
%  code12Wa.m -- 20 nov 02 -- djm
%
%  - single population code

clear
global ODE r1 a1

%  set ODE choice

disp(' ')
disp(' ODE choices:')
disp('   1) limits to growth')
disp('   2) rare encounters')
disp(' ')
setup = input('choose 1/2/R:  ');
disp(' ')
disp(' click to choose IV (bottom to quit)')
disp(' ')

switch setup
    case{1}
        r1 =  1;  a1 = 0.5;
    case{2}
        r1 = -1;  a1 = 0.5;
    otherwise
        break
end
   
figure(1);  clf;  hold on
title('\bf population model')
xlabel('\bf t-axis')
ylabel('\bf y(t)-axis')
axis([0 5 0 4])

IV = [];

while (isempty(IV))
    click = ginput(1);
    IV = click(2);
   
    if(IV<0)
        break
    end
    
%  invoke runge-kutta solver
    
    opt = odeset('RelTol',1e-3,'AbsTol',1e-6);
    [t y] = ode45(@Fode12Wa,[0 5],IV,opt);

    plot(t,y,'r')
    plot(0,IV,'ko')
    
    IV = [];
end
