Guided 3D simulation of an example 4 stage rocket

The rocket is simulated using a fixed-timestep integration. Pitchover occurs at a predetermined time.

See also GuidedLaunch3D, GuidedLaunch3DRHS.

%--------------------------------------------------------------------------
%	 Copyright (c) 2014 Princeton Satellite Systems, Inc.
%  All rights reserved.
%--------------------------------------------------------------------------

% Rocket
rocket = RocketDatabase('examplerocket');

% Launch site - latitude, longitude, altitude
lla0   = [0;-pi/2;11];

% Initial velocity (km/s) and flight path angle (rad)
vg0    = [.237; 81*pi/180];

% Target conditions, altitude, inclination, right ascension.
altDes = 350;         % km
incDes = 51.6*pi/180; % rad
raDes  = 0;           % rad
jD0 = JD2000;

% Parameters
% Specify pitchover angle and time, and whether to use J2 perturbations
params = GuidedLaunch3D;
params.fControl{1} = @ThrustControlGravityTurn;
params.fControl{2} = @ThrustControlConstantAngle;
params.fControl{3} = @ThrustControlConstantAngle;
params.fControl{4} = @ThrustControlRaiseApogee;
params.fParams{1} = struct('minAlt',0);
params.fParams{2} = struct('minAlt',0,'angle',0);
params.fParams{3} = struct('minAlt',0,'angle',5*pi/180);
params.fParams{4} = struct('rA',6378+altDes);

% Simulation
sim = GuidedLaunch3D( rocket, lla0, vg0, altDes, incDes, raDes, jD0, params )


%--------------------------------------
% PSS internal file version information
%--------------------------------------
Predicted burnout velocity: 9.174282 km/s, time: 480.189447 s
Stage 1, Alt 11.0 km, Vel 0.536 km/s, FPA 81.000 deg, VBar 0.068
Flight path angle after pitchover: 80.590901 deg, Alt 11.259 km, Vel 0.538 km/s
Stage 2, Alt 62.4 km, Vel 2.027 km/s, FPA 36.998 deg, VBar 0.258
Stage 3, Alt 124.6 km, Vel 4.397 km/s, FPA 5.671 deg, VBar 0.562
Stage 4, Alt 152.6 km, Vel 7.744 km/s, FPA 2.201 deg, VBar 0.991
Max altitude of 349.047318 km reached at 1341.300000 seconds.
sim = 
  struct with fields:

        input: [1×1 struct]
          VBO: [2.031035183493116 4.400645935719576 7.747323124475973]
      gammaBO: [0.575375139166721 0.096045839810440 0.042048173590978]
      thetaBO: [-0.011059093564242 -0.047492121749928 -0.129539762046870]
        altBO: [1×3 double]
      rangeBO: [1×3 double]
          kBO: [962 1796 2729]
       timeBO: [1×3 double]
        range: [1×27461 double]
          alt: [1×27461 double]
         time: [1×27461 double]
           xs: [10×27461 double]
          rOP: [3×27461 double]
          rEF: [3×27461 double]
        gamma: [1×27461 double]
        mFuel: [4×27461 double]
    thrustDir: [3×27461 double]
    thrustMag: [1×27461 double]