% Analysis and Simulation of the Predator UAV
%
% It is important that three codes be run in order.
%  First run this code to get the Predator "constant" vector defined and to 
%    establish a trim condition.
%  Second, run the nonlinear simulation in SIMULINK using FlatEarth.mdl.
%  Third, run FlatEarthAnal.m to get linear models and to 
%     overplot linear and nonlinear time responses.

% Quick trim the Predator
disp(' ')
disp('Start here')
% Get tne matrix of constants that pretain to the Predator.
RunFirst_Predator  % Remember that this code clears MATLAB memory
%                    and can clear time histories that may have been previously 
%                    generated by SIMULINK.
disp(aircraft); % Display aircraft identification

% Establish a trim condition (initial condition).
Vt=constant(58)% ft/sec
Hp=constant(59)
[xIC,uIC,CL,CD,CM,alphadeg]=QuickTrim(Vt,Hp,constant)
flag=1;
t=0;
% Check to insure that the derivatives of the state vector (sys) are small 
% for this trim condition.
[sys,x0,str,ts] = aircraft(t,xIC,uIC,flag,constant,xIC)

% Now we are ready to sun the nonlinear simulation using
% SIMULINK and FlatEarth.mdl.
