CubeSatDisturbanceAnalysis:

Path: CubeSat/AttitudeControl

% CubeSat disturbance analysis from batch data using RHSCubeSat. 
 Compute the drag, magnetic, gravity gradient, and optical disturbances. The
 environment is computed using AtmJ70, BDipole, and SunV1. AtmDens2
 can be used instead by supplying an empty matrix for d.atm.

 The built-in demo computes the disturbances on a 3U satellite for one day.
 The center of mass is assumed to be offset from the geometric center of the
 spacecraft by a few cm. Note the growth in momentum. the gravity gradient
 torque is zero in the demo because the attitude entered is perfect LVLH and
 the inertia is symmetric.
------------------------------------------------------------------------
   Form:
   [tT, fECI, h, hECI, f, t, powers] = CubeSatDisturbanceAnalysis( d, q, r, v, jD )
   CubeSatDisturbanceAnalysis  % demo
------------------------------------------------------------------------

   ------
   Inputs
   ------
   d        (.)      Data structure from RHSCubeSat
   q       (4,:)     Quaternion, ECI to body
   r       (3,:)     Position vector
   v       (3,:)     Velocity vector
   jD      (1,:)     Julian dates

   -------
   Outputs
   -------
   tT      (3,:)   Torque in body (Nms)
   fECI    (3,:)   Force in ECI (N)
   h       (3,:)   Body momentum (Nms)
   hECI    (3,:)   ECI momentum (Nms)
   torque   (.)    Torque structure
                     .total   (3,:)  Torque in body frame
                     .aero    (3,:)  Aerodynamic torque
                     .mag     (3,:)  Magnetic torque
                     .optical (3,:)  Optical torque
                     .gg      (3,:)  Gravity gradient torque
   force    (.)    Force structure
                    .total   (3,:)  Force in ECI frame
                    .aero    (3,:)  Aerodynamic force
                    .optical (3,:)  Optical force
   powers (1,:)   Total power from the solar cells (W)

------------------------------------------------------------------------
   See also CubeSatAero, CubeSatRadiationPressure, GravityGradientFromR,
   RHSCubeSat
------------------------------------------------------------------------