 

% LATERAL ANALYSIS
%*****************

%                     LATERAL 
%           NON-DIMENSIONAL DERIVATIVES
%               NOT DEPENDENT ON CL 
% ***********************************************
% CyB..................Y force derivative wrt Beta
% ClB .................Roll Moment derivative wrt Beta
% CnB..................Yaw Moment derivative wrt Beta
% Cnr..................Yaw Moment derivative yaw rate
% Cyr..................Y force derivative wrt yaw rate
% Cydr.................Y force derivative wrt rudder deflection
% Cndr.................Yaw Moment derivative wrt rudder deflection
% Clp..................Roll Moment derivative wrt roll rate


%                     LATERAL 
%           NON-DIMENSIONAL DERIVATIVES
%                 DEPENDENT ON CL 
% ***********************************************

% Clr .................Roll Moment derivative wrt yaw rate
% Cnp..................Yaw Moment derivative wrt roll rate
% Cyp..................Y force derivative wrt roll rate
  



%        DIMENSIONAL DERIVATIVES
%************************************************
% LB .......   See Nelson for Explanation 
% YB ........
% NB ........
% Lr ........
% Yr ........
% Nr ........
% Ydr .......
% Ndr .......
% Lp  .......
% Yp  .......
% Np  .......
%************************************************


%              OTHER VARIABLES
%*************************************************************
% Q .................. Dynamic Pressure lbs/ft2
% Vt ................. Trim velocity ft/sec
% rho ................ Density slug/ft3
% Ix ................. X Moment of Inertia  slug.ft2
% Iz ................. Z Moment of Inertia  slug.ft2
% cw .................. Mean aerodynamic chord of the wing ft
% bw .................. Wing span
% Sw ................. Wing Reference Area ft2
% m .................. Aircraft Mass  slug
%*************************************************************



% Calculated Quantities 
%************************ 

  % Dynamic Pressure
  Q = 0.5*rho*Vt*Vt;







%             DIMENSIONAL DERIVATIVES
%************************************************

     k1 = Q*Sw*bw;


  LB = (k1/Ix)*ClB;  
  
  YB = (Q*Sw/m)*CyB; 

  NB = (k1/Iz)*CnB; 

  Lr = (k1*bw/2/Ix/Vt)*Clr; 

  Yr = (k1/2/m/Vt)*Cyr; 

  Nr = (k1*bw/2/Iz/Vt)*Cnr;
 
  Ydr = (Q*Sw/m)*Cydr;

  Ndr = (k1/Iz)*Cndr;

  Lp  = (k1*bw/2/Ix/Vt)*Clp;

  Np  = (k1*bw/2/Iz/Vt)*Cnp; 

  Yp  = (k1/2/m/Vt)*Cyp;

% *********************************************** 

 LB
 YB
 NB
 Lr
 Yr
 Nr
 Ydr
 Ndr
 Lp
 Np
 Yp


 pause







%      DUTCH ROLL STATE SPACE 
%***********************************

 a1 = [ YB/Vt  Yp/Vt -(1-Yr/Vt) g/Vt ];
 a2 = [ LB   Lp  Lr 0];
 a3 = [ NB  Np  Nr  0];
 a4 = [ 0 1 0 0 ]; 
 

 A =[a1; a2; a3; a4];

 B = [Ydr/Vt; 0;  Ndr; 0];

 C =[1 0 0 0; 0 0 1 0];

 D =[0; 0 ]; 


  [Lambda]= eig(A) 

  [Wndr, Zdr]= damp(A)
 
%***********************************





%***********APPROXIMATIONS***********



%           SPIRAL MODE
%***********************************
   
  lspiral =  (LB*Nr - Lr*NB)/LB
 
%***********************************


%            ROLL MODE
%*********************************** 


  Lroll = Lp

  Roll_Time_Constant = -1/Lp

%***********************************




[num,den]=ss2tf(A,B,C,D)






