Documentation of midprefs


Global Index (short | long) | Local contents | Local Index (short | long)


Function Synopsis

midprefs(xidpath,dum)

Help text

MIDPREFS Choose directory for idprefs.mat, the ident start-up info file.

   midprefs  or midprefs(PATH)

   The Graphical User Interface to the System Identification toolbox
   uses a file idprefs.mat to store start-up information, like preferred
   window sizes and locations and most recently used session files.
   By default this file is stored in the same directory as startup.m,
   if this .m file exists.

   To select another directory, use the function MIDPREFS. Simply type
   the function name and follow the instructions, or give the directory
   as an argument. Include all directory delimiters.

   Example (PC): midprefs('c:\matlab\toolbox\local\')

Cross-Reference Information

This function calls This function is called by

Listing of function midprefs

function midprefs(xidpath,dum)

%   L. Ljung 1-1-95
%   Copyright (c) 1986-98 by The MathWorks, Inc.
%   $Revision: 2.4 $  $Date: 1997/12/02 03:40:35 $

global XIDlaypath XIDsessions XIDlayout

if exist('idprefs.mat')
   load idprefs.mat
else
   XIDlaypath=[];
   if ~exist('XIDsessions'), XIDsessions=[];end   
   if ~exist('XIDlayout'), XIDlayout=[];end
end
XIDpathold=XIDlaypath;
if nargin==1, 
  if ~(xidpath(end)==filesep),xidpath=[xidpath,filesep];end
  tstpath=findstr([path,pathsep],[xidpath(1:end-1),pathsep]); 
  if isempty(tstpath)
    errordlg(['The given path is not on your MATLABPATH. Please ',...
	  'select another path.'])
    return
  end
  XIDlaypath=xidpath;
elseif nargin==0
  text1='You have currently no file idprefs.mat on your MATLABPATH.';
  text2=['idprefs.mat currently stored in ',XIDpathold.'.'];
  text3=str2mat(['Use the MATLAB file finder to select a directory',...
      ' where to put this file.'],...
      'The directory should be on your regular MATLABPATH.','',...
      'Press Cancel in the file finder to abort.','',...
      'Press Return to open the file finder.','');
  if isempty(XIDpathold)
    disp(str2mat(text1,text3))
  else
    disp(str2mat(text2,text3))
  end
  pause
end  
if nargin==0|nargin==2
  okfile=1;
  while okfile
  [dum,XIDlaypath]=uiputfile('idprefs.mat','Directory for start-up file');
  if XIDlaypath==0,XIDlaypath=[];return;end
  tstpath=findstr(path,XIDlaypath(1:end-1));
  if isempty(tstpath)
    click=questdlg(['The given path is not on your MATLABPATH. Please ',...
	  'select another path.'],'Warning','OK','Cancel','OK');
    if strcmp(lower(click),'cancel'),return,end
  else
    okfile=0;
  end  
  end
end
err=0;
eval(['save ',XIDlaypath,...
         'idprefs.mat XIDlaypath XIDsessions XIDlayout'],'err=1;')
if err,
       errordlg(['File could not be written. Check writing permissions', ...
	   ' and pathname']),return
end

 
disp(str2mat('',['Ident start-up info stored in ',XIDlaypath,'idprefs.mat.'],''))
del=0;
if ~isempty(XIDpathold)
    eval(['delete ',XIDpathold,'idprefs.mat'],''),del=1;
    disp(str2mat(['Old file ',XIDpathold,'idprefs.mat deleted.'],''))
end