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

📄 aclin.m

📁 MATLAB在飞行动力学和控制中应用的工具
💻 M
📖 第 1 页 / 共 4 页
字号:
         beta   = input('sideslip angle [rad]    : ');
         p      = input('roll-rate [rad/s]       : ');
         q      = input('pitch-rate [rad/s]      : ');
         r      = input('yaw-rate [rad/s]        : ');
         psi    = input('yaw-angle [rad]         : ');
         theta  = input('pitch-angle [rad]       : ');
         phi    = input('roll-angle [rad]        : ');
         xe     = input('x-coordinate [m]        : ');
         ye     = input('y-coordinate [m]        : ');
         H      = input('altitude [m]            : ');

         xinco  = [V alpha beta p q r psi theta phi xe ye H]';

         % Ask if state vector is correct. If not, re-enter, or go back
         % to main menu. If the length of the state vector is too short,
         % because the user has pressed <ENTER> without giving a number
         % for one or more of the states, the state-vector must be
         % re-entered by the user too.
         % ---------------------------------------------------------------
         disp(' ');

         if length(xinco) == 12    % xinco has right number of elements
            clc
            disp('Current definition of state vector:');
            xinco

            answ = input('Is this correct (y/n)? ','s');
            if answ == 'y'
               ok1 = 1;            % leave loop for entering xinco
            else
               disp(' ');
               answ1 = input('Proceed with manual definition (y/n)? ','s');
               if answ1 == 'n'
                  proceed = 0;     % do not proceed with manual definition
               end
            end
            clear answ answ1

         else                      % length of xinco is NOT right
            clc
            disp('State vector is too short! You probably have pressed');
            disp('<ENTER> without entering a value for one or more states.');
            disp(' ');

            answ1 = input('Proceed with manual definition (y/n)? ','s');
            if answ1 == 'n'
               proceed = 0;     % do not proceed with manual definition
            else
               disp(' ');
               disp('Please re-enter state vector.');
            end
            clear answ1

            disp(' ');
            disp('<<< Press a key >>>');
            pause
            clc
         end
      end

      % While-loop for correctly entering the aerodynamic inputs.
      % ---------------------------------------------------------
      ok1 = 0;        % If ok1 == 1, the while-loop for entering uaero0
                      % will be quitted; proceed with definition of uprop0,
                      % unless user has chosen to quit manual definition
                      % of user point (then proceed == 0).

      while ok1 ~= 1 & proceed == 1

         clc
         disp('Aerodynamic inputs: [deltae deltaa deltar deltaf]''');
         disp(' ');
         deltae = input('elevator angle [rad]     : ');
         deltaa = input('ailerons deflection [rad]: ');
         deltar = input('rudder angle [rad]       : ');
         deltaf = input('flap angle [rad]         : ');

         uaero0 = [deltae deltaa deltar deltaf]';

         % Ask if aerodynamic inputvector is correct. If not, re-enter. If
         % the length of the aerodynamic inputvector is too short because
         % the user has pressed <ENTER> without giving a number for one or
         % more inputs, this inputvector must be re-entered by the user.
         % ---------------------------------------------------------------
         disp(' ');

         if length(uaero0) == 4  % uaero0 has right number of elements
            clc
            disp('Current definition of inputvector to aerodynamic model:');
            uaero0

            answ = input('Is this correct (y/n)? ','s');
            if answ == 'y'
               ok1 = 1;           % leave while-loop to define uaero0
            else
               disp(' ');
               answ1 = input('Proceed with manual definition (y/n)? ','s');
               if answ1 == 'n'
                  proceed = 0;     % do not proceed with manual definition
               end
            end
            clear answ answ1

         else                      % length of uaero0 is NOT right
            clc
            disp('Inputvector is too short! You probably have pressed');
            disp('<ENTER> without entering a value for one or more inputs.');
            disp(' ');

            answ1 = input('Proceed with manual definition (y/n)? ','s');
            if answ1 == 'n'
               proceed = 0;     % do not proceed with manual definition
            else
               disp(' ');
               disp('Please re-enter state vector.');
            end
            clear answ1

            disp(' ');
            disp('<<< Press a key >>>');
            pause
         end
      end

      % While-loop for correctly entering the engine inputvector.
      % ---------------------------------------------------------
      ok1 = 0;        % If ok1 == 1, the while-loop for entering uprop0
                      % will be quitted, and definitions of xinco, uaero0, and
                      % uprop0 entered so far will be used in linearization,
                      % unless the user already has specified that the
                      % manual operating point definition must be stopped,
                      % in which case proceed == 0.

      while ok1 ~= 1 & proceed == 1

         clc
         disp('Engine inputs: [n pz]''');
         disp(' ');
         n      = input('engine speed [RPM]       : ');
         pz     = input('manifold pressure ["Hg]  : ');

         uprop0 = [n pz]';

         % Ask if engine-inputvector is correct. If not, re-enter. If
         % the length of the engine-inputvector is too short because
         % the user has pressed <ENTER> without giving a number for one or
         % more inputs, this inputvector must be re-entered by the user.
         % ---------------------------------------------------------------
         disp(' ');

         if length(uprop0) == 2       % uprop0 has right length
            clc
            disp('Current definition of inputvector to engine model:');
            uprop0

            answ = input('Is this correct (y/n)? ','s');
            if answ == 'y'
               ok1 = 1;
            else
               disp(' ');
               answ1 = input('Proceed with manual definition (y/n)? ','s');
               if answ1 == 'n'
                  proceed = 0;     % do not proceed with manual definition
               end

            end
            clear answ answ1

         else                      % length of uprop0 is NOT right
            clc
            disp('Inputvector is too short! You probably have pressed');
            disp('<ENTER> without entering a value for one or more inputs.');
            disp(' ');

            answ1 = input('Proceed with manual definition (y/n)? ','s');
            if answ1 == 'n'
               proceed = 0;     % do not proceed with manual definition
            else
               disp(' ');
               disp('Please re-enter state vector.');
            end
            clear answ1

            disp(' ');
            disp('<<< Press a key >>>');
            pause
         end
      end

      % Operating point is now defined by xinco, uaero0, and uprop0. Now
      % we'll clear variables which are not needed anymore.
      % ----------------------------------------------------------------
      clear V alpha beta p q r psi theta phi xe ye H deltae deltaa deltar
      clear deltaf n pz ok1

      % If user has not chosen to leave manual definition of operating point,
      % the variable proceed will still be equal to one. Then, it is right
      % to leave operating point definition, assuming that the current de-
      % finition is correct. Otherwise, go back to main menu (ok ~= 1!).
      % ---------------------------------------------------------------------
      if proceed == 1
         ok = 1;
      end

      clear proceed

   elseif opt == 3                     % USE OPERATING POINT FROM WORKSPACE
                                       % ----------------------------------
      clc
      if exist('xinco') == 0 | exist('uaero0') == 0 | exist('uprop0') == 0
         % Currently, no operating point has been defined in the Matlab
         % workspace. Display error message and return to main menu.
         % ------------------------------------------------------------
         clc
         disp('ACLIN expects the following variables to be present in the');
         disp('Matlab workspace:');
         disp(' ');
         disp('   xinco = state vector in operating point');
         disp('   uaero0= vector with aerodynamic control inputs');
         disp('   uprop0= vector with engine control inputs');
         disp(' ');
         disp('At least one of these vectors is currently not present, so');
         disp('linearization cannot proceed!');
         disp(' ');
         disp('<<<Press a key to return to main menu>>>');
         pause
      else
         % Ask if current definition of the operating point is correct.
         % If not, program will return to main menu.
         % ------------------------------------------------------------
         clc
         disp('Current definition of operating point (xinco = states,');
         disp('uaero0 = aerodynamic inputs, uprop0 = engine inputs):');
         xinco
         uaero0
         uprop0
         answ = input('Is this correct (y/n)? ','s');
         if answ ~= 'y'
            disp(' ');
            disp('<<<Press a key to return to main menu>>>');
            pause
         else
            ok = 1;  % If current definition is ok, proceed with
                     % linearization
         end
         clear answ
      end

   elseif opt == 4   % RUN ACTRIM TO DETERMINE STEADY-STATE TRIMMED-FLIGHT
                     % CONDITION. Type HELP ACTRIM for more details.
                     % ---------------------------------------------------

      % ACTRIM computes xinco, xdot0, uprop0, and uaero0. Before calling
      % ACTRIM, these variables are cleared to make sure that they will not
      % become mixed-up with the results of ACTRIM if they already exist.
      % To prevent other variables, used in ACLIN from intervening with
      % ACTRIM, all variables will be saved to a temporary file ACLIN.TMP.
      % The worspace will be cleared before starting ACTRIM. If ACTRIM has
      % finished, the old variables will be retrieved from ACLIN.TMP, and
      % the temporary file will be deleted.
      % ---------------------------------------------------------------------
      clear uaero0 uprop0 xinco xdot0 % delete operating point definition
                                %                from workspace (if present)
      save aclin.tmp            % save remaining variables to temporary file
      clear                     % ... and clear workspace

      actrim                    % run ACTRIM

      load aclin.tmp -mat       % retrieve variables from temporary file
      delete('aclin.tmp');

      % Operating point definition is valid only if ACTRIM actually has
      % computed something. If option 'Quit' was selected in ACTRIM, the
      % workspace does not contain a valid definition of the operating
      % point; ok = 1 (quit operating point definition loop) is therefore
      % defined only if xinco, uprop0, and uaero0 exist.
      % -----------------------------------------------------------------

⌨️ 快捷键说明

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