RHSOpt2DOrbit:

--------------------------------------------------------------------------
   Right-hand-side for the planar orbit optimization problem. 
   Includes only radial position, radial velocity and tangential velocity.
   This function is specifically for the minimum time problem. It is designed
   to be called by ode113. The terminal condition is the orbit radius of the
   target which precludes optimal orbits that may go outside this radius.

   Since version 7.
--------------------------------------------------------------------------
   Form:
   varargout = RHSOpt2DOrbit( t, x, flag, d )
--------------------------------------------------------------------------

   ------
   Inputs
   ------
   t          (1,1)  Time
   x          (7,1)  States [r;u;v;lambda]
   flag       (1,1)  Flag from ode113
   d          (1,1)  Structure to pass to the integration RHS
                     .accel (1,1) The acceleration

   -------
   Outputs
   -------
   xDot       (4,1)  State derivatives d[r;u;v;lamDot;vOR]/dt

   or

   vnew       (1,1)  Value of constraint
   isterminal (1,1)  1 if a terminal constraint  
   direction  (1,1)  Direction  

--------------------------------------------------------------------------