⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aclin.m

📁 MATLAB在飞行动力学和控制中应用的工具
💻 M
📖 第 1 页 / 共 4 页
字号:
% The FDC toolbox. Linearization routine ACLIN.
% =============================================
% ACLIN is a Matlab program, which can be used to linearize air-
% craft models in SIMULINK. These models must have the same in-
% put/output structure as the system BEAVER from the FDC toolbox
% In ACLIN, it is possible to simplify the resulting linear state-
% space model, e.g. to neglect longitudinal/lateral cross-coupling.
%
% ACLIN can be applied to all aircraft models which use the same
% definitions of the input and state vectors as the system BEAVER:
%
% x = [V alpha beta p q r psi theta phi xe ye H]',
% u = [deltae deltaa deltar deltaf n pz,
%                                   ,uw vw ww uwdot vwdot wwdot]'
%
% where: V      = airspeed [m/s]
%        alpha  = angle of attack [rad]
%        beta   = sideslip angle [rad]
%        p      = roll rate [rad/s]
%        q      = pitch rate [rad/s]
%        r      = yaw rate [rad/s]
%        psi    = yaw angle [rad]
%        theta  = pitch angle [rad]
%        phi    = roll angle [rad]
%        xe     = X-coordinate in Earth-fixed reference frame [m]
%        ye     = Y-coordinate in Earth-fixed reference frame [m]
%        H      = altitude above sea-level [m]
%
% and:   deltae = elevator deflection [rad]
%        deltaa = ailerons deflection [rad]
%        deltar = rudder deflection [rad]
%        deltaf = flap setting [rad]
%        n      = engine speed [RPM]
%        pz     = manifold pressure ["Hg]
%        uw     = wind & turbulence speed along Xb-axis [m/s]
%        vw     = wind & turbulence speed along Yb-axis [m/s]
%        ww     = wind & turbulence speed along Zb-axis [m/s]
%        uwdot  = d(ut)/dt [m/s^2]
%        vwdot  = d(vt)/dt [m/s^2]
%        wwdot  = d(vt)/dt [m/s^2]
%
% ACLIN uses the Simulink function LINMOD, with default lineari-
% zation options. For the 'Beaver' model, this yields satisfying
% results. However, if you customize the aircraft model, it is
% advisable to experiment somewhat with these options (type HELP
% LINMOD for more info). If you want to change the linearization
% options or apply this program to aircraft models with other
% definitions of the state and input vectors, ACLIN needs to be
% edited. Many comment lines have been added to facilitate this.
%
% It is important to realize that 99% of the program code of ACLIN
% consists of a user-interface to define the operating point, and
% select the states and inputs for the linearized model. The ac-
% tual linearization algorithm is contained in the Simulink uti-
% lity LINMOD! If you want to experiment with different lineari-
% zation algorithms, you should write your own program, based
% upon LINMOD.M, and replace the call of LINMOD within the program
% ACLIN by a call to your own linearization program.
%
% See also ACTRIM for more info about the determination of steady-
% state trimmed-flight conditions (which may be used as operating
% point definitions for ACLIN).


% List of variables for ACLIN
% ===========================
% Aac         system matrix of linearized aircraft model
% Aac_s       system matrix of 'simplified' linearized model
% allinputs   flag variable which is set to 1 if the user wants to use all
%             twelve input variables for the linearized models, or 0 if the
%             user wants to extract a limited number of inputs from the
%             linearized model
% allstates   flag variable which is set to 1 if the user wants to use all
%             twelve state variables for the linearized models, or 0 if the
%             user wants to extract a limited number of state variables from
%             the linearized model
% alpha       angle of attack [rad]
% answ        general: string variable used for storing user answers to
%             yes/no questions
% answ1       same as answ for nested questions
% Bac         system matrix of linearized aircraft model
% Bac_s       system matrix of 'simplified' linearized model
% beta        sideslip angle [rad]
% Cac         system matrix of linearized aircraft model
% Cac_s       system matrix of 'simplified' linearized model
% Dac         system matrix of linearized aircraft model
% Dac_s       system matrix of 'simplified' linearized model
% datadir     not a variable but a Matlab function, determines the default
%             data-directory for the FDC toolbox
% defdir      default directory where the FDC toolbox stores and searches for
%             datafiles
% deltaa      ailerons deflection [rad]
% deltae      elevator angle [rad]
% delttaf     flap angle [rad]
% deltar      rudder angle [rad]
% dirname     string variable with name of data-directory, entered by the user
% filename    string variable with name of datafile, entered by the user
% H           altitude [m]
% ii          counter
% jj          counter
% lindef      text matrix with information about the linearized model (examine
%             this matrix to find out the definitions of state-vector, input-
%             vector, simplified state and input vectors, operating point
%             definition, etc.)
% line#       string vectors, used to fill the text matrix 'lindef' with
%             information about the linearized model
% loadcmmnd   string variable in which the load-command is defined (used if
%             the user wants to load an operating point from file, where the
%             names of the file, file-extension, and data-directory are ob-
%             tained from the variables filename, and dirname)
% n           engine speed [RPM]
% ok          in general: flag used for while-loops in which the user must
%             enter certain parameters, etc.; while-loop is not quitted until
%             this variable has got the value 1 (for instance if the user has
%             acknowledged that the user-input is correct)
% ok1,ok2,... other flags, used for nested while-loops
% opt         variable used in user-menu's, which determines which menu option
%             has been selected by the user (exact meaning explained in source
%             text)
% p           roll-rate [rad/s]
% phi         roll-angle [rad]
% proceed     flag which is set to 0 if the user wants to quit the manual
%             operating-point definition; used to 'break' the corresponding
%             while-loop
% psi         yaw-angle [rad]
% pz          manifold pressure ["Hg]
% q           pitch-rate [rad/s]
% r           yaw-rate [rad/s]
% savecmmnd   string variable which specifies which results to save in which
%             file
% setdir      not a variable but a Matlab function that is called for letting
%             the user specify a directory name
% skip        flag which is set to 1 if user wants to quit the program; in
%             that case some parts of the program are skipped
% sysname     string variable, contains the name of the system to be linea-
%             rized
% t           time (t = clock, type HELP CLOCK for more info)
% t1          hours, extracted from t
% t2          minutes, extracted from t
% t3          seconds, extracted from t
% theta       pitch-angle [rad]
% trimdef     text matrix with information about the trimmed-flight operating
%             point (exists only if the user retrieves the operating point
%             from a file, created by ACTRIM, or if ACTRIM itself is called
%             during the operating point definition for the linearization
%             routine)
% uaero0      vector with initial values of aerodynamic control inputs,
%             defines operating point for the linearization routine
% udef        vector with numbers of the input variables which the user wants
%             to extract from the total of six control inputs and six wind &
%             turbulence inputs from the linearized model
% uinco       initial input vector, consists of uaero0, uprop0, and a zero-
%             value wind & turbulence vector
% uprop0      vector with initial values of engine control inputs, defines
%             operating point for the linearization routine
% V           airspeed [m/s]
% xdef        vector with numbers of the state variables which the user wants
%             to extract from the total of twelve state variables from the
%             linearized model
% xe          X-coordinate [m]
% xfix        gain variable which is used to specify states that should be
%             artificially fixed to their initial values (xfix is either equal
%             to 1 or equal to a vector of length twelve with elements that
%             equal 0 or 1, see the help-file XFIX.HLP or type HELP FIXSTATE
%             at the Matlab command line)
% xinco       initial value of the state vector, defines operating point for
%             linearization routine
% ye          Y-coordinate [m]
%-----------------------------------------------------------------------------

format short e

skip = 0;         % Help variable which is set to 1 if user selects
                  % QUIT from main menu. If skip = 1, the last part of
                  % ACLIN, where the actual linearization takes place,
                  % is skipped.

% Welcome...
% ----------
clc
disp('FDC 1.2 - ACLIN');
disp(' ');
disp('Linearize nonlinear aircraft model in SIMULINK.');
disp('===============================================');
disp(' ');

% Enter name of the aircraft model.
% ---------------------------------
disp('Enter name of the aircraft model in Simulink (default: BEAVER)');
sysname = input('> ','s');
if isempty(sysname)
   sysname = 'beaver';
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Define or load operating point.
% ===============================

ok = 0;
while ok ~= 1  % While-loop for correctly entering or loading operating
               % point. Normally, loop will be quitted directly, but if
               % definitions are not OK, operating point definition will
               % start all over again. If ok == 1, while-loop will be
               % left, and ACLIN will proceed with model parameter defi-
               % nition and linearization itself.
               % -------------------------------------------------------
   clc
   opt = menu('Choose one of the following options:',...
         'Load operating point from file',...
         'Manually define operating point',...
         'Use operating point defined in workspace',...
         'Run ACTRIM to determine trimmed flight condition',...
         'Quit');

   if opt == 1                                       % LOAD OPERATING POINT
                                                     % --------------------

         % Define default data-directory by calling the subroutine DATADIR.M
         % (which is also used by other FDC subroutines).
         % -----------------------------------------------------------------
         defdir     = datadir;

         % If default directory exists, temporarily switch to that directory.
         % ------------------------------------------------------------------
         currentdir = chdir;
         eval(['chdir ',defdir,';'],['chdir ',currentdir,';']);

         % Obtain filename and path.
         % -------------------------
         [filename,dirname] = uigetfile('*.tri',...
                                        'Load operating point from file');

         loadcmmnd=['load ',dirname,filename, ' -mat'];
         eval([loadcmmnd,'; ok = 1;'],'disp(''File not found!'')');

         % Back to previous directory
         % --------------------------
         eval(['chdir ',currentdir,';']);

   elseif opt == 2                        % MANUALLY DEFINE OPERATING POINT
                                          % -------------------------------
      clc
      disp('Manually define operating point.');
      disp('--------------------------------');

      % While-loop for correctly entering the state vector.
      % ---------------------------------------------------
      ok1 = 0;        % If ok1 == 1, the while-loop for entering xinco
                      % will be quitted; proceed with definition of uaero0.

      proceed = 1;    % If proceed == 0, the while-loop for entering xinco
                      % will be quitted, and manual definition will stop.

      while ok1 ~= 1 & proceed == 1
         disp(' ');
         disp('State vector: [V alpha beta p q r psi theta phi xe ye H]''');
         disp(' ');

         % While-loop to make sure that V has a value unequal to zero. User
         % must select a reasonable V himself, but at least this check makes
         % sure that no 'Division by zero errors' will occur in the Simulink
         % system of the nonlinear aircraft model.
         % -----------------------------------------------------------------
         ok2 = 0;
         while ok2 ~= 1
            V = input('airspeed [m/s]          : ');
            if V == 0
               disp(' ');
               disp('V must have a value > 0!');
            else
               ok2 = 1;
            end
         end
         clear ok2

         alpha  = input('angle of attack [rad]   : ');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -