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

📄 aclin.m

📁 matlab的FDC工具箱
💻 M
📖 第 1 页 / 共 4 页
字号:
         % ---------------------------------------------------------------
         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 isempty(answ)
               answ = 'n';
            end
            if answ == 'y'
               ok1 = 1;            % leave loop for entering xinco
            else
               disp(' ');
               answ1 = input('Proceed with manual definition ([y]/n)? ','s');
               if isempty(answ1)
                  answ1 = 'y';
               end
               if answ1 == 'n'
                  proceed = 0;     % do not proceed with manual definition
               end
            end

         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 isempty(answ1)
               answ1 = 'y';
            end
            if answ1 == 'n'
               proceed = 0;     % do not proceed with manual definition
            else
               disp(' ');
               disp('Please re-enter state vector.');
            end

            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], default = 0: ');
         if isempty(deltae), deltae = 0; end;
         deltaa = input('ailerons deflection [rad], default = 0: ');
         if isempty(deltaa), deltaa = 0; end;
         deltar = input('rudder angle [rad], default = 0: ');
         if isempty(deltar), deltar = 0; end;
         deltaf = input('flap angle [rad], default = 0: ');
         if isempty(deltaf), deltaf = 0; end;

         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 isempty(answ)
               answ = 'n';
            end
            if answ == 'y'
               ok1 = 1;           % leave while-loop to define uaero0
            else
               disp(' ');
               answ1 = input('Proceed with manual definition ([y]/n)? ','s');
               if isempty(answ1)
                  answ1 = 'y';
               end
               if answ1 == 'n'
                  proceed = 0;     % do not proceed with manual definition
               end
            end

         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 isempty(answ1)
               answ1 = 'y';
            end
            if answ1 == 'n'
               proceed = 0;     % do not proceed with manual definition
            else
               disp(' ');
               disp('Please re-enter state vector.');
            end

            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], default = 2000: ');    if isempty(n), n = 2000; end;
         pz = input('manifold pressure ["Hg], default = 20: '); if isempty(pz), pz = 20; end;

         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 isempty(answ)
               answ = 'n';
            end
            if answ == 'y'
               ok1 = 1;
            else
               disp(' ');
               answ1 = input('Proceed with manual definition ([y]/n)? ','s');
               if isempty(answ1)
                  answ1 = 'y';
               end
               if answ1 == 'n'
                  proceed = 0;     % do not proceed with manual definition
               end

            end

         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 isempty(answ1)
               answ1 = 'y';
            end
            if answ1 == 'n'
               proceed = 0;     % do not proceed with manual definition
            else
               disp(' ');
               disp('Please re-enter state vector.');
            end

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

      % 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

   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 isempty(answ) | 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
      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

⌨️ 快捷键说明

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