Home > atmlab > examples > startup_menu.m

startup_menu

PURPOSE ^

STARTUP_MENU Menu to start different environments at startup.

SYNOPSIS ^

function startup_menu( choice )

DESCRIPTION ^

 STARTUP_MENU   Menu to start different environments at startup.

    This is an example how it is possible to select different configurations
    of Matlab in a rather simple way. The function shows also example on
    how some default settings of Matlab can be changed. The function is
    neither perfect or complete. Copy it if you like it and make the
    modifications you want.

    If you always want to run this function at startup, there are two
    options:
      1. Rename this function to startup.m and make sure it is found
         by Matlab at startup.
      2. Call this function from your existing startup.m.

    If you want to change the environment during a Matlab session, give
    the environment number as input and execute this function (if it is
    still in the search path).

 FORMAT   startup_menu( [choice] )
        
 OPT   choice  If given, no menu is displayed and the input argument is
               taken as the choice from the menu. No type and ragne checks
               are performed, and an invalid choice will give a crash without
               proper error message.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

DOWNLOAD ^

startup_menu.m

SOURCE CODE ^

0001 % STARTUP_MENU   Menu to start different environments at startup.
0002 %
0003 %    This is an example how it is possible to select different configurations
0004 %    of Matlab in a rather simple way. The function shows also example on
0005 %    how some default settings of Matlab can be changed. The function is
0006 %    neither perfect or complete. Copy it if you like it and make the
0007 %    modifications you want.
0008 %
0009 %    If you always want to run this function at startup, there are two
0010 %    options:
0011 %      1. Rename this function to startup.m and make sure it is found
0012 %         by Matlab at startup.
0013 %      2. Call this function from your existing startup.m.
0014 %
0015 %    If you want to change the environment during a Matlab session, give
0016 %    the environment number as input and execute this function (if it is
0017 %    still in the search path).
0018 %
0019 % FORMAT   startup_menu( [choice] )
0020 %
0021 % OPT   choice  If given, no menu is displayed and the input argument is
0022 %               taken as the choice from the menu. No type and ragne checks
0023 %               are performed, and an invalid choice will give a crash without
0024 %               proper error message.
0025 
0026 % 2002-12-19   Created by Patrick Eriksson.
0027 
0028 function startup_menu( choice )
0029 
0030 
0031 %=== Clean the path
0032 %
0033 path(pathdef);
0034 
0035 
0036 if nargin == 0
0037 
0038   choice = local_ASCIImenu( 'What to run?', { ...
0039                  'Pure Matlab',                 ...       % 1
0040                  'Only default settings',       ...       % 2 
0041                  'WWW',                         ...       % 3
0042                  'Qpack',                       ...       % 4
0043                  'Qsmr',                        ...       % 5
0044                  'Atmlab',                      ...       % 6
0045                  'Qoso'                     } );          % 7
0046 
0047 end
0048 
0049 
0050 switch choice
0051 
0052   case 1
0053     package = 'pure Matlab';   
0054     cd /home/patrick
0055 
0056   case 2
0057     package = 'only default settings';   
0058     startup_general_defs;
0059     cd /home/patrick
0060 
0061   case 3
0062     package = 'WWW';
0063     cd /home/patrick/HTML/WWW
0064 
0065   case 4
0066     package = 'Qpack';
0067     startup_general_defs;
0068     cd /home/patrick/ARTS/arts1/ami
0069     init;
0070     cd /home/patrick/ARTS/Qpack
0071     qpack_startup;
0072     cd Samples
0073 
0074   case 5
0075     package = 'Qsmr';
0076     startup_qsmr;
0077 
0078   case 6
0079     package = 'Atmlab';
0080     cd /home/patrick/ARTS/atmlab/atmlab
0081     atmlab_init;
0082     cd ..
0083 
0084   case 7
0085     package = 'Qoso';
0086     startup_general_defs;
0087     cd /home/patrick/Projects/Onsala/Qoso
0088     qoso_startup;
0089 
0090 end
0091 
0092 
0093 disp( sprintf('\n\n----- Welcome to %s -----\n\n', package ) );
0094 
0095 
0096 
0097 %
0098 % Various general default settings.
0099 %
0100 
0101 function startup_general_defs
0102 
0103 
0104   %=== These lines turn off the menu and toolbar in the plot windows
0105   %
0106   if strcmp(computer,'SOL2')
0107     set(0,'DefaultFigureMenuBar','none');
0108   elseif strcmp(computer,'LNX86') | strcmp(computer,'GLNX86')
0109     set(0,'DefaultUimenuVisible','off');
0110     set(0,'DefaultFigureToolbar','none');
0111   else
0112     error('Unknown computer type.');
0113   end
0114     
0115     
0116   %=== Give default values for plot windows
0117   %
0118   ax_size   = 12;            %size of axes text
0119   ax_weight = 'bold';            %normal or bold axes text
0120   %
0121   tx_size   = 12;            %size of text
0122   tx_weight = 'normal';            %normal or bold text
0123 
0124 
0125 
0126   %=== Set coler order for plot lines
0127   %
0128   corder = [
0129   0.00 0.00 1.00        %blue
0130   1.00 0.00 0.00        %red
0131   0.00 1.00 0.00        %green
0132   1.00 0.00 1.00
0133   0.00 1.00 1.00
0134   1.00 1.00 0.00
0135   ];
0136 
0137 
0138   %=== Printing
0139   %
0140   %= Set paper size to A4
0141   set(0,'DefaultFigurePaperType','A4');
0142   %
0143   %= Give printed figures the same size as on the screen
0144   set(0,'DefaultFigurePaperPositionMode','auto');
0145 
0146 
0147   %==========================================================================
0148   % Set some values defined above
0149   %
0150   %=== Set default values for plot windows
0151   set(0,'DefaultAxesFontWeight',ax_weight);
0152   set(0,'DefaultAxesFontSize',ax_size);
0153   set(0,'DefaultTextFontWeight',tx_weight);
0154   set(0,'DefaultTextFontSize',tx_size);
0155   set(0,'DefaultAxesColorOrder',corder);
0156 
0157 return
0158 
0159 
0160 
0161 %
0162 % The code below is copied, with some improvements, from menu.m
0163 %
0164 
0165 function k = local_ASCIImenu( xHeader, xcItems )
0166 
0167 
0168 %-------------------------------------------------------------------------
0169 % Calculate the number of items in the menu
0170 %-------------------------------------------------------------------------
0171 numItems = length(xcItems);
0172 
0173 %-------------------------------------------------------------------------
0174 % Continuous loop to redisplay menu until the user makes a valid choice
0175 %-------------------------------------------------------------------------
0176 while 1,
0177     % Display the header
0178     disp(' ')
0179     disp(['----- ',xHeader,' -----'])
0180     disp(' ')
0181     % Display items in a numbered list
0182     for n = 1 : numItems
0183         disp( [ '      ' int2str(n) ') ' xcItems{n} ] )
0184     end
0185     disp(' ')
0186     % Prompt for user input
0187     k = input('Select a menu number: ');
0188     % Check input:
0189     % 1) make sure k has a value
0190     if isempty(k), k = -1; end;
0191     % 2) make sure the value of k is valid
0192     if  (k < 1) | (k > numItems) ...
0193         | ~strcmp(class(k),'double') | rem(k,1) ~= 0 ...
0194         | ~isreal(k) | (isnan(k)) | isinf(k),
0195         % Failed a key test. Ask question again
0196         disp(' ')
0197         disp('Invalid selection. Try again.')
0198     else
0199         % Passed all tests, exit loop and return k
0200         return
0201     end % if k...
0202 end % while 1
0203 
0204 
0205 
0206

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005