function [a,phi,gam,c,d,q,x0,dt,rowinq,b]=ml_p2ss3(p)
%----------------------------------------------------------------------------
%P2SS FUNCTION FOR ML_DEMO3.M  --------- EXTENSIVELY COMMENTED AS A TUTORIAL
%        SIMPLE MODEL OF CH47 IN HOVER. THE PHUGOID MODE IS UNSTABLE.
%----------------------------------------------------------------------------
%---------- p = [ 1   2   3   4   5   6   7 ] ---- PARAMETERS NORMALIZED
%                 Zw  Mu  Mq  Mb  Zc  Qw  Qq       FOR AESTHETIC REASONS
%---------------------------------------------------- STABILITY DERIVATIVES
a=[0         0            0           -.3196; % -g Cos(Pitch trim attitude)
   0         -.28*p(1)    0           -.037 ; %    Sin
   .96*p(2)  0            -1.008*p(3)   0   ;
   0         0             1            0   ];
%------------------------------------------------------ CONTROL DERIVATIVES
b=[0           0;
   0    -.8*p(5); %   Zc
   3*p(4)      0; %   Mb
   0           0];
%------------------------------------------------------- MEASUREMENT MATRIX
c=diag([1 .573 .573 1]); %  OUTPUT IN DEGREES FOR DERIVS IN .O1 RADS
%---------------------------------------------------------- FEEDTHRU MATRIX
d=zeros(4,2);
%--------------------------------------------------- STATE NOISE COVARIANCE
q=diag([1e-10   p(6)/1000  p(7)/1000 1e-10]);%    Q*Q'   MUST BE POS DEF!
%-------------------------------------- ROWS IN Q IN WHICH PARAMETERS OCCUR
rowinq=[0 0 0 0 0 2 3];
%------------------------------------- [U,W,Q,THETA] = INITIAL STATE VECTOR
x0=[0 0 0 0]; %    UNITS= FT/S, FT/S,  .01RAD/S,  .01RAD
%------------------------------------------------- DEFINE dt AND DISCRETIZE
dt=.05; [phi,gam]=c2d(a,b,dt);
%----------------------------------------------------------- end ml_p2ss3.m

