%
%   SHOOTM2.M   Example of Shooting Method for Solving ODEs
%
%   This is a follow up to demo SHOOTM1.M.  This file simply generates the 
%   plots obtained for each of the guesses for the ALF used in SHOOTM1.M
%   The goal was to find the ALF at x = 0 which gives y(pi) = 0.
%
%   also see SHOOTF.M - contains description of given differential equation
%      y'' + 3xy' + 7y  =  cos(2x)      with  y(0) = 1  and  y(pi) = 0
%
%   File prepared by J. R. White, UMass-Lowell  (Aug. 2003)
%

%
%   getting started
      clear all, close all, nfig = 0;
%
%   with manual procedure, ALFs of 1, -1, and -5.4713 were used in SHOOTM1.M
%   let's plot the function for these different guesses to see how this works
      gs = [1 -1 -5.4715];
%
%   set domain limits and solve IVP
      xo = 0;   xf = pi;    tol = 1.0e-6;   yxo = 1.0;
      options = odeset('RelTol',tol);
      [x1,z1] = ode23('shootf',[xo xf],[yxo gs(1)],options);
      [x2,z2] = ode23('shootf',[xo xf],[yxo gs(2)],options);
      [x3,z3] = ode23('shootf',[xo xf],[yxo gs(3)],options);
%
%   now plot results 
      nfig = nfig+1;  figure(nfig)
      plot(x1,z1(:,1),'g-',x2,z2(:,1),'r-.',x3,z3(:,1),'b--','LineWidth',2)
      title('ShootM2:  Shooting Method for ODEs (Case 1 - Manual Iteration)')
      xlabel('x values'),ylabel('y values'),grid
      legend('alf = 1','alf = -1','alf = -5.4715')
%
%   end of demo

