         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
   -0.0833         0         0         0         0         0         0
    0.6667   -0.0833         0         0         0         0         0
         0    0.6667   -0.0833         0         0         0         0
   -0.6667         0    0.6667   -0.0833         0         0         0
    0.0833   -0.6667         0    0.6667   -0.0833         0         0
         0    0.0833   -0.6667         0    0.6667   -0.0833         0
         0         0    0.0833   -0.6667         0    0.6667   -0.0833
         0         0         0    0.0833   -0.6667         0    0.6667
         0         0         0         0    0.0833   -0.6667         0
         0         0         0         0         0    0.0833   -0.6667
         0         0         0         0         0         0    0.0833
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0

  Columns 36 through 42 

         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
   -0.0833         0         0         0         0         0         0
    0.6667   -0.0833         0         0         0         0         0
         0    0.6667   -0.0833         0         0         0         0
   -0.6667         0    0.6667   -0.0833         0         0         0
    0.0833   -0.6667         0    0.6667   -0.0833         0         0
         0    0.0833   -0.6667         0    0.6667   -0.0833         0
         0         0    0.0833   -0.6667         0    0.6667   -0.0833
         0         0         0    0.0833   -0.6667         0    0.6667
         0         0         0         0    0.0833   -0.6667         0
         0         0         0         0         0    0.0833   -0.6667
         0         0         0         0         0         0    0.0833
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0

  Columns 43 through 49 

         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
   -0.0833         0         0         0         0         0         0
    0.6667   -0.0833         0         0         0         0         0
         0    0.6667   -0.0833         0         0         0         0
   -0.6667         0    0.6667   -0.0833         0         0         0
    0.0833   -0.6667         0    0.6667   -0.0833         0         0
         0    0.0833   -0.6667         0    0.6667   -0.0833         0
         0         0    0.0833   -0.6667         0    0.6667   -0.0833
         0         0         0    0.0833   -0.6667         0    0.6667
         0         0         0         0    0.0833   -0.6667         0
         0         0         0         0         0    0.0833   -0.6667
         0         0         0         0         0         0    0.0833
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0

  Columns 50 through 56 

         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
   -0.0833         0         0         0         0         0         0
    0.6667   -0.0833         0         0         0         0         0
         0    0.6667   -0.0833         0         0         0         0
   -0.6667         0    0.6667   -0.0833         0         0         0
    0.0833   -0.6667         0    0.6667   -0.0833         0         0
         0    0.0833   -0.6667         0    0.6667   -0.0833         0
         0         0    0.0833   -0.6667         0    0.6667   -0.0833
         0         0         0    0.0833   -0.6667         0    0.6667
         0         0         0         0    0.0833   -0.6667         0
         0         0         0         0         0    0.0833   -0.6667
         0         0         0         0         0         0    0.0833
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0

  Columns 57 through 63 

         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
         0         0         0         0         0         0         0
   -0.0833         0         0         0         0         0         0
    0.6667   -0.0833         0         0         0         0         0
         0    0.6667   -0.0833         0         0         0         0
   -0.6667         0    0.6667   -0.0833         0         0         0
    0.0833   -0.6667         0    0.6667   -0.0833         0         0
         0    0.0833   -0.6667         0    0.6667   -0.0833         0
         0         0    0.0833   -0.6667         0    0.6667   -0.0833
         0         0         0    0.0833   -0.6667         0    0.6667
         0         0         0         0    0.0833   -0.6667         0
         0         0         0         0   -0.0833    0.5000   -1.5000
         0         0         0         0    0.2500   -1.3333    3.0000

  Columns 64 through 65 

         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
         0         0
   -0.0833         0
    0.6667   -0.0833
    0.8333    0.2500
   -4.0000    2.0833

>> spy(fd)
>> help spy

 SPY Visualize sparsity pattern.
    SPY(S) plots the sparsity pattern of the matrix S.
 
    SPY(S,'LineSpec') uses the color and marker from the line
    specification string 'LineSpec' (See PLOT for possibilities).
 
    SPY(S,markersize) uses the specified marker size instead of
    a size which depends upon the figure size and the matrix order.
 
    SPY(S,'LineSpec',markersize) sets both.

>> [t,y] = ode45('west',[0,1],-1/2);
>> size(t)

ans =

    41     1

>> ref0 = odeset('refine',1);
>> [t0,y0] = ode45('west',[0,1],-1/2,ref0);
>> size(t0)

ans =

    11     1

>> plot(t0,y0,'k+',t,y,'r.')
>> help odeset

 ODESET Create/alter ODE OPTIONS structure.
    OPTIONS = ODESET('NAME1',VALUE1,'NAME2',VALUE2,...) creates an integrator
    options structure OPTIONS in which the named properties have the
    specified values. Any unspecified properties have default values. It is
    sufficient to type only the leading characters that uniquely identify the
    property. Case is ignored for property names. 
    
    OPTIONS = ODESET(OLDOPTS,'NAME1',VALUE1,...) alters an existing options
    structure OLDOPTS.
    
    OPTIONS = ODESET(OLDOPTS,NEWOPTS) combines an existing options structure
    OLDOPTS with a new options structure NEWOPTS. Any new properties
    overwrite corresponding old properties. 
    
    ODESET with no input arguments displays all property names and their
    possible values.
    
 ODESET PROPERTIES
    
 RelTol - Relative error tolerance  [ positive scalar {1e-3} ]
    This scalar applies to all components of the solution vector, and
    defaults to 1e-3 (0.1% accuracy) in all solvers.  The estimated error in
    each integration step satisfies e(i) <= max(RelTol*abs(y(i)),AbsTol(i)).
 
 AbsTol - Absolute error tolerance  [ positive scalar or vector {1e-6} ]
    A scalar tolerance applies to all components of the solution vector.
    Elements of a vector of tolerances apply to corresponding components of
    the solution vector. AbsTol defaults to 1e-6 in all solvers. See RelTol.
    
 NormControl -  Control error relative to norm of solution  [ on | {off} ]
    Set this property 'on' to request that the solvers control the error in
    each integration step with norm(e) <= max(RelTol*norm(y),AbsTol). By
    default the solvers use a more stringent component-wise error control. 
    
 Refine - Output refinement factor  [ positive integer ]
    This property increases the number of output points by the specified
    factor producing smoother output. Refine defaults to 1 in all solvers 
    except ODE45, where it is 4. Refine does not apply if length(TSPAN) > 2 
    or the ODE solver returns the solution as a structure.
    
 OutputFcn - Installable output function  [ function ]
    This output function is called by the solver after each time step. When
    a solver is called with no output arguments, OutputFcn defaults to the
    function odeplot. Otherwise, OutputFcn defaults to [].
    
 OutputSel - Output selection indices  [ vector of integers ]
    This vector of indices specifies which components of the solution vector
    are passed to the OutputFcn. OutputSel defaults to all components.
    
 Stats - Display computational cost statistics  [ on | {off} ]
    
 Jacobian - Jacobian function [ function | constant matrix ]
    Set this property to a function FJac (if FJac(t,y) returns dF/dy) or to
    the constant value of dF/dy.   
       
 JPattern - Jacobian sparsity pattern [ sparse matrix ]
    Set this property to a sparse matrix S with S(i,j) = 1 if component i of
    F(t,y) depends on component j of y, and 0 otherwise.
    
 Vectorized - Vectorized ODE function  [ on | {off} ]
    Set this property 'on' if the ODE function F is coded so that 
    F(t,[y1 y2 ...]) returns [F(t,y1) F(t,y2) ...]. 
    
 Events - Locate events  [ function ]
    To detect events, set this property to the event function.
    
 Mass - Mass matrix [ constant matrix | function ]
    For problems M*y' = f(t,y) set this property to the value of the constant
    mass matrix. For problems with time- or state-dependent mass matrices,
    set this property to a function that evaluates the mass matrix.
 
 MStateDependence - Dependence of the mass matrix on y [ none | {weak} | strong ] 
    Set this property to 'none' for problems M(t)*y' = F(t,y). Both 'weak' and
    'strong' indicate M(t,y), but 'weak' will result in implicit solvers
    using approximations when solving algebraic equations.
    
 MassSingular - Mass matrix is singular  [ yes | no | {maybe} ]
    Set this property to 'no' if the mass matrix is not singular.
 
 MvPattern - dMv/dy sparsity pattern [ sparse matrix ]
    Set this property to a sparse matrix S with S(i,j) = 1 if for any k, the 
    (i,k) component of M(t,y) depends on component j of y, and 0 otherwise.  
 
 InitialSlope - Consistent initial slope yp0 [ vector ]
    yp0 satisfies M(t0,y0)*yp0 = F(t0,y0).
 
 InitialStep - Suggested initial step size  [ positive scalar ]
    The solver will try this first.  By default the solvers determine an
    initial step size automatically. 
    
 MaxStep - Upper bound on step size  [ positive scalar ]
    MaxStep defaults to one-tenth of the tspan interval in all solvers.
 
 BDF - Use Backward Differentiation Formulas in ODE15S  [ on | {off} ]
    This property specifies whether the Backward Differentiation Formulas
    (Gear's methods) are to be used in ODE15S instead of the default
    Numerical Differentiation Formulas. 
 
 MaxOrder - Maximum order of ODE15S  [ 1 | 2 | 3 | 4 | {5} ]
    
    See also ODEGET, ODE45, ODE23, ODE113, ODE15S, ODE23S, ODE23T, ODE23TB.
 
 
    NOTE: 
      Some of the properties available through ODESET have changed in this
      version of MATLAB. Although we still support the v5 properties when
      used with the v5 syntax of the ODE solvers, any new functionality will
      be available only with the new syntax. To see the properties available
      in v5, type in the command line  
          more on, type odeset, more off

>> stiffopts = odeset('refine',16);
>> [ts,ys] = ode15s('stiff',[0,2*pi],2,stiffopts);
>> [ds,zs,fds] = residual( ts, ys, 'stiff', 16 );
>> plot( ts, ds )
>> plot( ts, ys )
>> ds(1)

ans =

   40.9490

>> size(ts)

ans =

   945     1

>> ds(945)

ans =

 -1.4340e-004

>> truesol = exp(-1000*ts) + cos(ts);
>> ferr = ys - truesol;
>> plot( t, ferr )
??? Error using ==> plot
Vectors must be the same lengths.

>> plot( t, ferr' )
??? Error using ==> plot
Vectors must be the same lengths.

>> plot( ts, ferr' )
>> stiffopts = odeset('refine',16,'reltol',1.e-8,'abstol',1.e-8);
>> [ts,ys] = ode15s('stiff',[0,2*pi],2,stiffopts);
>> size(ts)

ans =

        4433           1

>> [ds,zs,fds] = residual( ts, ys, 'stiff', 16 );
>> plot( ts, ds )
>> ferr = ys - truesol;
??? Error using ==> -
Matrix dimensions must agree.

>> truesol = exp(-1000*ts) + cos(ts);
>> ferr = ys - truesol;
>> plot( ts, ferr )
>> 