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

📄 aclin.m

📁 MATLAB在飞行动力学和控制中应用的工具
💻 M
📖 第 1 页 / 共 4 页
字号:
      disp(' ');
   end
   disp('<<< Press a key >>>');
   pause

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

   % Create a text matrix with information about the linearized model.
   % Note: the function NUM2STR2 is just a slightly changed version
   % of NUM2STR. Type HELP NUM2STR2 at the Matlab command line  for
   % more info.
   % =================================================================
   line1  = ['Linearized aircraft model of the system ' sysname ':'];
   line2  = '';
   line3  = ['User-specified operating point:'];
   line4  = '';
   line5  = ['Airspeed:          V      =  ' num2str2(xinco(1),10)  ' [m/s]'  ];
   line6  = ['Angle of attack:   alpha  =  ' num2str2(xinco(2),10)  ' [rad]'  ];
   line7  = ['Sideslip angle:    beta   =  ' num2str2(xinco(3),10)  ' [rad]'  ];
   line8  = ['Roll-rate:         p      =  ' num2str2(xinco(4),10)  ' [rad/s]'];
   line9  = ['Pitch-rate:        q      =  ' num2str2(xinco(5),10)  ' [rad/s]'];
   line10 = ['Yaw-rate:          r      =  ' num2str2(xinco(6),10)  ' [rad/s]'];
   line11 = ['Yaw-angle:         psi    =  ' num2str2(xinco(7),10)  ' [rad]  '];
   line12 = ['Pitch-angle:       theta  =  ' num2str2(xinco(8),10)  ' [rad]  '];
   line13 = ['Roll-angle:        phi    =  ' num2str2(xinco(9),10)  ' [rad]  '];
   line14 = ['X-coordinate:      xe     =  ' num2str2(xinco(10),10) ' [m]    '];
   line15 = ['Y-coordinate:      ye     =  ' num2str2(xinco(11),10) ' [m]    '];
   line16 = ['Altitude:          H      =  ' num2str2(xinco(12),10) ' [m]    '];
   line17 = '';
   line18 = ['Elevator angle:    deltae =  ' num2str2(uaero0(1),10) ' [rad]  '];
   line19 = ['Aileron angle:     deltaa =  ' num2str2(uaero0(2),10) ' [rad]  '];
   line20 = ['Rudder angle:      deltar =  ' num2str2(uaero0(3),10) ' [rad]  '];
   line21 = ['Flap angle:        deltaf =  ' num2str2(uaero0(4),10) ' [rad]  '];
   line22 = '';
   line23 = ['Engine speed:      n      =  ' num2str2(uprop0(1),10) ' [RPM]  '];
   line24 = ['Manifold pressure: pz     =  ' num2str2(uprop0(2),10) ' ["Hg]  '];
   line25 = '';
   line26 = ['Full state space model: Aac, Bac, Cac, Dac.'];
   line27 = '';

   % Add definition of Aac_s and Bac_s to text matrix.
   % -------------------------------------------------
   if allstates == 1 & allinputs == 1  % all states and all outputs selected,
                                       % so no model simplifications...
      line28 = ['No simplified model available.'];
      line29 = '';
      line30 = ['x     =  [V alpha beta p q r psi theta phi xe ye H]'''];
      line31 = ['u     =  [ua'' ut'' uwind'']'''];
      line32 = '';
      line33 = ['ua    =  [deltae deltaa deltar deltaf]'''];
      line34 = ['ut    =  [n pz]'','];
      line35 = ['uwind =  [uw vw ww uwdot vwdot wwdot]'''];
      line36 = '';

   else                            % simplified model has been determined

      line28 = ['Aac_s and Bac_s contain simplified model (state eqs. only!)'];
      line29 = '';

      line30 = ['State and input vectors of the simplified model:'];

      line31 = ['x_s=['];
      for ii = 1:length(xdef)
         line31 = [line31 'x(' num2str(xdef(ii)) ') '];
      end
      line31 = [line31(1:length(line31)-1) ']'];

      line32 = ['u_s=['];
      for jj = 1:length(udef)
         line32 = [line32 'u(' num2str(udef(jj)) ') '];
      end
      line32 = [line32(1:length(line32)-1) ']'];

      clear ii jj

      line33 = '';
      line34 = ['where: x = [V alpha beta p q r psi theta phi xe ye H]'''];
      line35 = ['       u = [deltae deltaa deltar deltaf n pz  ...'];
      line36 = ['                     ...  uw vw ww uwdot vwdot wwdot]'''];

   end

   line37 = '';

   % Add time and date to text matrix.
   % ---------------------------------
   t  = clock;
   t1 = num2str(t(4));
   t2 = num2str(t(5));
   t3 = num2str(t(6));

   line38 = ['date: ', date, '   time: ', t1, ':', t2, ':', t3];

   clear t t1 t2 t3


   % Now all explanatory lines will be enhanced to 80 characters,
   % in order to fit them into one string matrix.
   % ------------------------------------------------------------
   line1  = [line1  blanks(79-length(line1 ))];
   line2  = [line2  blanks(79-length(line2 ))];
   line3  = [line3  blanks(79-length(line3 ))];
   line4  = [line4  blanks(79-length(line4 ))];
   line5  = [line5  blanks(79-length(line5 ))];
   line6  = [line6  blanks(79-length(line6 ))];
   line7  = [line7  blanks(79-length(line7 ))];
   line8  = [line8  blanks(79-length(line8 ))];
   line9  = [line9  blanks(79-length(line9 ))];
   line10 = [line10 blanks(79-length(line10))];
   line11 = [line11 blanks(79-length(line11))];
   line12 = [line12 blanks(79-length(line12))];
   line13 = [line13 blanks(79-length(line13))];
   line14 = [line14 blanks(79-length(line14))];
   line15 = [line15 blanks(79-length(line15))];
   line16 = [line16 blanks(79-length(line16))];
   line17 = [line17 blanks(79-length(line17))];
   line18 = [line18 blanks(79-length(line18))];
   line19 = [line19 blanks(79-length(line19))];
   line20 = [line20 blanks(79-length(line20))];
   line21 = [line21 blanks(79-length(line21))];
   line22 = [line22 blanks(79-length(line22))];
   line23 = [line23 blanks(79-length(line23))];
   line24 = [line24 blanks(79-length(line24))];
   line25 = [line25 blanks(79-length(line25))];
   line26 = [line26 blanks(79-length(line26))];
   line27 = [line27 blanks(79-length(line27))];
   line28 = [line28 blanks(79-length(line28))];
   line29 = [line29 blanks(79-length(line29))];
   line30 = [line30 blanks(79-length(line30))];
   line31 = [line31 blanks(79-length(line31))];
   line32 = [line32 blanks(79-length(line32))];
   line33 = [line33 blanks(79-length(line33))];
   line34 = [line34 blanks(79-length(line34))];
   line35 = [line35 blanks(79-length(line35))];
   line36 = [line36 blanks(79-length(line36))];
   line37 = [line37 blanks(79-length(line37))];
   line38 = [line38 blanks(79-length(line38))];


   % The explanatory lines are collected in the matrix lindef.
   % ---------------------------------------------------------
   lindef = [line1;  line2;  line3;  line4;  line5;  line6;  line7;  line8;
             line9;  line10; line11; line12; line13; line14; line15; line16;
             line17; line18; line19; line20; line21; line22; line23; line24;
             line25; line26; line27; line28; line29; line30; line31; line32;
             line33; line34; line35; line36; line37; line38];

   clear line1  line1a line2  line3  line4  line5  line6  line7  line8  line9
   clear line10 line11 line12 line13 line14 line15 line16 line17 line18 line19
   clear line20 line21 line22 line23 line24 line25 line26 line27 line28 line29
   clear line30 line31 line32 line33 line34 line35 line36 line37 line38


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


   % Results can now be saved to a file, which will be filled with the
   % state space matrices Aac, Bac, Cac, Dac of the linearized aircraft
   % model, and the information matrix lindef. Moreover, the user will
   % be asked if the operating point, defined by xinco, uaero0, and uprop0
   % must be saved to the same file too. In that case, the information
   % matrix trimdef will be saved too if it exists (see ACTRIM for more
   % info).
   %
   % Note: files with linearized aircraft model have extension .LIN!
   % ==================================================================
   clc
   answ = input('Save linear state-space model to file (y/n)? ','s');
   if answ == 'y'

      % Go to default directory if that directory exists (if not, start
      % save-routine from the current directory).
      % ---------------------------------------------------------------
      eval(['chdir ',defdir,';'],['chdir ',currentdir,';']);

      % Obtain filename and path.
      % -------------------------
      [filename,dirname] = uiputfile('*.lin','Save linearized model');

      % Build string variable which specifies what to save in which file.
      % -----------------------------------------------------------------
      savecmmnd=['save ',dirname,filename,' Aac Bac Cac Dac lindef'];
      if allstates ~= 1 | allinputs ~= 1         % simplified matrices exist?
         savecmmnd = [savecmmnd ' Aac_s Bac_s']; %    ... then save them too!
      end

      % Ask if operating point needs to be included to the .LIN file. If it
      % does, add xinco, uaero0, uprop0 and (if present) trimdef to the list
      % of variables to be saved. The text matrix trimdef should be pre-
      % sent in the workspace if the operating point has been determined
      % directly by calling ACTRIM or by loading it from a .TRI-file.
      % -----------------------------------------------------------------
      disp(' ');
      answ = input('Include operating point {xinco,uaero0,uprop0} to file (y/n)? ','s');
      if answ == 'y'
         savecmmnd = [savecmmnd ' xinco uaero0 uprop0'];
         % If operating point has been loaded from .TRI file or computed by
         % directly calling ACTRIM, the definition of the trimmed flight-
         % condition is stored in the text-matrix trimdef. If the operating
         % point is defined in another way, this matrix does not exist. If
         % trimdef exists, it will be saved along with the trimmed flight-
         % condition itself.
         % -----------------------------------------------------------------
         if exist('trimdef') == 1
            savecmmnd = [savecmmnd ' trimdef'];
         end
      end
      clear answ

      % Save linearized model to file (evaluate savecmmnd).
      % ---------------------------------------------------
      clc
      disp('Saving linear state-space model to the file:');
      disp(' ');
      disp(['     ',dirname,filename]);
      disp(' ');

      eval(savecmmnd)

      disp('<<< Press a key >>>');
      pause
   end
   clear answ dirname filename savecmmnd defdir currentdir

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

   % Display results for user.
   % =========================
   clc
   disp('State-space matrices of linearized aircraft model: Aac, Bac, Cac,');
   disp('and Dac (ac = aircraft). Operating point is defined by the vectors');
   disp('xinco, uaero0, and uprop0.');
   disp(' ');
   pause(1.5)
   disp('Examine the nonlinear aircraft model in Simulink for the current');
   disp('definition of the outputvector. The S-function BEAVER uses:');
   disp(' ');
   disp(' y = [x'' dH/dt pb/2V qc/V rb/2V]''');
   disp(' ');
   disp('which contains all relevant information for the autopilot simu-');
   disp('lation model APILOT.');
   disp(' ');

   if allstates ~= 1 | allinputs ~= 1
      disp('Simplified state model available in matrices Aac_s and Bac_s');
      disp('(state equations only!).');
      disp(' ');
   end

   disp('See matrix lindef for more details!');

end % of the part of the program in which the actual linearization takes
    % place, and which contains the save routines (skipped if the option
    % QUIT is selected from the main menu).

disp(' ');
disp('Ready.');
disp(' ');

% Clear variables which are not needed anymore
% --------------------------------------------
clear opt skip sysname uinco udef xdef allstates allinputs ii jj


%---------------------------------------------------------------------------------
% The FDC toolbox. Copyright Marc Rauw, 1994-2000.
% Last revision of this program: October 10, 1997.
%
% History of this file, starting September 8, 1997:
% =================================================
% September 8, 1997
%  - Replaced cd commands with chdir to enhance compatibility
% October 10, 1997
%  - Replaced DOS delete command with general Matlab version

⌨️ 快捷键说明

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