%phase_pendulum.m

clear all
clc

loop=1;

xmin=-8;
xmax=8;
ymin=-2;
ymax=2;

%options = odeset('OutputFcn','odephas2');

figure(1)
clf;

Tfinal=input('Enter final time:  ');

while (loop==1)
   clc
   keepgoing=input('Enter 0 to end:  ');
   if keepgoing==0
      break;
   end
   ax_choice=input('Enter 0 to change axes:  ');
   if ax_choice==0
      xmin=input('xmin:  ');
      xmax=input('xmax:  ');
      ymin=input('ymin:  ');
      ymax=input('ymax:  ');
   end

   TSPAN=[0 Tfinal];
   x10=input('Enter x10:  ');
   x20=input('Enter x20:  ');
   Y0=[x10; x20];
   figure(1)
   hold on
   [T,Y]=ode45('phase_pendulum_fun',TSPAN,Y0);
   plot(Y(:,1),Y(:,2),'r-')
   axis([xmin xmax ymin ymax])
   xlabel('x1')
   ylabel('x2')
end
hold off

