%
%   ODENEX2.M   Solution of ODEs with MATLAB  (IVP)  
%
%   This demo gives an example of how to use the ODE23 routine to integrate
%   a simple first order differential equation.  A slight extension to vectors
%   allows the solution of systems of first order ODEs.  This extension will be 
%   treated in later examples (see section on General IVPs).
%
%   also see ODENEX2A.M - function file for use in ODE23
%
%   This example solves   y' = (x^2 + 3y^2)/(2xy)   with    y(1) = 2
%   and compares to exact soln   y(x) = x*sqrt(5x-1)
%
%   File prepared by J. R. White, UMass-Lowell (July 2003)
%

%
%   getting started
      clear all, close all,  nfig = 0;
%
%   initial setup 
      xo = 1;   xf = 3;   yo = 2;   tol = .0001;
%
%   evaluate exact solution
      Nx = 31;   xe = linspace(xo,xf,Nx);   ye = xe.*sqrt(5*xe-1);
%   
%   now evaluate numerical solution (using ODE23)
      options = odeset('RelTol',tol);
      [x1,y1] = ode23('odenex2a',[xo,xf],yo,options);
%
%   now plot results (numerical(points), exact(solid))
      figure(1)
      plot(xe,ye,'b-',x1,y1,'ro','LineWidth',2)
      title('ODEnex2:  Numerical & Analytical Solutions to 1st Order ODE')
      xlabel('x values'),ylabel('y(x)'),grid
      legend('EXACT','ODE23');
%
%   end of simulation