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

📄 fdcinit.m

📁 一个非常好的基于MATLAB的飞机动态控制工具箱,对于从事该方面研究的读者非常有参考价值
💻 M
📖 第 1 页 / 共 2 页
字号:
%------------------------------------------------------------------
% FDCINIT temporarily enhances the Matlabpath with the FDC root-
% and subfolders. This eases the pressure on the Matlabpath for
% non-frequent users of the FDC toolbox.
%
% FDCINIT creates a datafile called FDCINIT.INI in the root of the
% main folder of Simulink, which contains the extension to the
% Matlabpath, needed for FDC to run properly. It is possible to
% change the Matlabpath extension afterwards, that is: to change
% the names of the folders, to add subfolders, or to delete
% subfolders.
%
% The standard tree-structure for the FDC-package is:
%
% Root-folder:
%           MATLABROOT\TOOLBOX\FDC13\
%
% (note: FDC 1.3 SR1 applies generic path and file-separators, even
% though the documentation is still based upon MD DOS path-notation).
%
% Subfolders:
%           AIRCRAFT  contains the general aircraft model
%           APILOT    contains the autopilot simulation models
%           DATA      used for storing model parameters and other
%                     datafiles (e.g. trim conditions)
%           DOC       contains program documentation (README-files)
%           EXAMPLES  contains open-loop FDC examples
%           HELP      contains help texts for the FDC models
%           NAVIGATE  contains a library with VOR/ILS blocks
%           TOOLS     contains a TOOLS library (Simulink) and pro-
%                     grams for aircraft trim and linearization
%           WIND      contains a wind and turbulence library
%
% When FDCINIT is used for the first time, this standard path will
% be used as starting point for the Matlab-path extension for FDC
% (except for the subfolder DOC, which won't be needed during
% 'normal' FDC sessions). If the user changes this path, the new
% definition will be saved to the file FDCINIT.INI as default set-
% ting. Each time FDCINIT is used, the tree definition will be
% displayed, and the user will be asked if the path needs to be
% changed. It is possible to suppress this message for future runs
% of FDCINIT, in which case the path-definition cannot be changed
% anymore unless FDCINIT.INI is deleted first.
%
% Note: the file FDCINIT.INI is also used by ACTRIM, ACLIN, and
% LOADER to define a default folder in places where results need
% to be saved. If FDCINIT.INI is not present, these routines will
% all use DEFAULT defaults (if you know what I mean).
%------------------------------------------------------------------
clc
errorflag = 0;

% The extension of the Matlabpath is stored in pathext; pathtmp
% is a temporary path-variable, used to delete unwanted space in
% the path extension.
% --------------------------------------------------------------
pathext = [];
pathtmp = [];

if exist('fdcinit.ini') == 0   % Path definition has not been created yet,
                               % use default definitions as starting point.
                               % ------------------------------------------

   % The root folder of the Matlabpath extension (i.e., the FDC root) is
   % stored in rootdir. MATLABROOT\TOOLBOX\FDC13 is the default definition.
   % ----------------------------------------------------------------------
   rootdir = fullfile(matlabroot,'toolbox','fdc13');

   % The definition of the subfolders of the FDC package are stored in
   % subdirs (folder = directory). Default definitions are given below:
   % ------------------------------------------------------------------
   subdirs = ['aircraft'; 'apilot  '; 'data    '; 'examples';
              'help    '; 'navigate'; 'tools   '; 'wind    '];

   % The default definition of the Matlabpath extension will be used and the
   % user will be asked if that's correct (if not, the Matlab-path extension
   % can be changed). This question will appear every next time FDCINIT is
   % used, but it is possible to suppress the message for future sessions.
   % The variable 'suppress' is used to check this. If suppress = 0 (default)
   % the "is this correct" message will appear when starting FDCINIT; if the
   % user selects the option "suppress this message", suppress = 1 will be
   % set, and the message will not appear the next times FDCINIT is started.
   % Redefining the folder tree afterwards is then only possible after
   % deleting the file FDCINIT.INI before running FDCINIT again.
   % ------------------------------------------------------------------------
   suppress = 0;

else

   % Load definition of the Matlabpath extension and suppress variable
   % from the initialization file FDCINIT.INI.
   % -----------------------------------------------------------------
   load fdcinit.ini -mat

end

% Display welcome messages
% ------------------------
fdc_welc;     % welcome screen
pause;        % show until user presses a key
close(gcf);

% Display path information, unless user has selected 'suppress' option
% during an earlier FDC session.
% --------------------------------------------------------------------
if suppress ~= 1
   if exist('fdcinit.ini') == 0  % First time use: more details shown
      clc
      disp('Current Matlabpath extension for the FDC toolbox:');
      disp(' ');
      disp('FDC root-folder:');
      disp('----------------');
      disp(['   ',matlabroot,filesep,'TOOLBOX',filesep,'FDC13']);
      disp(' ');
      disp('FDC subfolders:');
      disp('---------------');
      disp('   AIRCRAFT    nonlinear aircraft model and model libraries');
      disp('   APILOT      autopilot simulation models');
      disp('   DATA        model parameters and other FDC datafiles');
      disp('   EXAMPLES    examples and tutorials');
      disp('   HELP        on-line help texts');
      disp('   NAVIGATE    radio-navigation library (VOR, ILS)');
      disp('   TOOLS       analytical tools, general blocklibrary, etc.');
      disp('   WIND        wind and turbulence blocks');
      disp(' ');
      disp('By default this definition should be allright. Change only if');
      disp('really neccessary!');
      disp(' ');

   else

      disp('Current Matlabpath-extension for the FDC toolbox:');
      disp(' ');
      disp(['FDC root folder:    ', rootdir]);
      disp(' ');
      disp(['FDC subfolders:     ', subdirs(1,:)]);
      [m,n] = size(subdirs);

      for i = 2:m
         disp(['                    ', subdirs(i,:)]);
      end

      disp(' ');

   end
end

if suppress == 0  % Do not skip the "Is this correct?"-message (definition
                  % from FDCINIT.INI will be used if suppress == 1). The
                  % variable suppress is stored in the file FDCINIT.INI.
                  % ------------------------------------------------------
   answ=input('FDC path ok? ([y]=yes, n=no, s=suppress this message in future): ','s');

   if isempty(answ)
      answ = 'y';
   end
   if answ == 'n'
      % Change Matlabpath extension.
      % -----------------------------
      ready = 0;
      while ready ~= 1
         clc
         opt = menu('Options','Change FDC root folder',...
                    'Rename or delete FDC subfolders',...
                    'Add FDC subfolders','Close');

         if opt == 1        % Change root folder.
                            % -------------------
            disp(' ');
            disp(' ');
            disp(['Current FDC root: ' rootdir]);
            disp(' ');

            % Enter new name of root folder (including root drive).
            % --------------------------------------------------------
            newroot = input('New root folder: ','s');
            if ~isempty(newroot)
               rootdir = newroot;
               clear newroot
            end

         elseif opt == 2    % Change or delete subfolders.
                            % ----------------------------
            disp(' ');
            disp(' ');
            newsubs = [];
            for i = 1:m     % For all subfolders: ask if changes have to
                            % be made, if the subdir has to be deleted from
                            % the path, or if old subfolder must be used.
                            % ----------------------------------------------
               disp(' ');
               disp(' ');
               disp(['Subfolder ' num2str(i) ': ' subdirs(i,:)]);
               disp(' ');

               answ2 = '';
               while isempty(answ2)
                  answ2 = input('c = change, d = delete from path, s = skip: ','s');
               end

               if answ2 == 'c'
                  newname = input('New subfolder [<= 8 characters!]: ','s');
                  if isempty(newname)
                     newname = subdirs(i,:);
                  end

                  % Check length of new entries, to make sure that folder
                  % name is not too long, and to add spaces to folder name
                  % if it has less than eight characters.
                  % ------------------------------------------------------
                  L = length(newname);
                  if L > 8
                     error('Directory name must be shorter than 9 characters!');
                  elseif L < 8
                     for ii = 1:(8-L)  % add spaces to newsub to get sub-
                                       % folder name of 8 characters.
                        newname = [newname ' '];
                     end
                  end

                  % New subfolder stored in newsubs.
                  % --------------------------------
                  newsubs = [newsubs; newname];

               elseif answ2 == 'd'

                  % Don't store a foldername in newsubs (has the same
                  % effect as deleting a foldername from the variable
                  % subdirs!).
                  % -------------------------------------------------
                  disp(' ');
                  disp(['subfolder ' subdirs(i,:) ' deleted!']);

               else

                  % Store old subfolder from FDCINIT.INI or
                  % the default folders (used if FDCINIT.INI doesn't
                  % exist yet) in variable newsubs.
                  % ------------------------------------------------
                  newsubs = [newsubs; subdirs(i,:)];

               end

            end

            % Use new folder tree, stored in newsubs, instead of the old
            % definition, which was stored in subdirs (overwrite subdirs).
            % ------------------------------------------------------------
            subdirs = newsubs;
            [m,n] = size(subdirs); % To prevent errors when subfolder-

⌨️ 快捷键说明

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