Desktop Tools and Development Environment |
Using the Path in Future Sessions
There are three basic ways for MATLAB to automatically use a search path you specify, each with advantages and disadvantages:
For background information, see How MATLAB Finds the Search Path, pathdef.m.
Modifying the Path in a startup.m File
Put addpath
and rmpath
statements in a startup
.m
file, and include the startup
file in MATLAB's startup directory. When MATLAB starts, it uses the search path defined in pathdef.m
in $matlabroot/toolbox/local
and modifies it based on the commands in the startup.m
file.
By maintaining an unaltered pathdef.m
in $matlabroot/toolbox/local
, you avoid inadvertently removing directories supplied by The MathWorks from the path. This method continues working even when you update to a new version of MATLAB. If you run MATLAB on both Windows and UNIX platforms, this method works well--for example, for each platform, include separate addpath
sections in the startup.m
file, with each section preceded by an ispc
or isunix
statement.
One disadvantage of this method is that changes you make to the path using the Set Path dialog box are not incorporated in the startup.m
file.
Saving the Path in the MATLAB Startup Directory
Copy pathdef.m
from $matlabroot/toolbox/local
to the MATLAB startup directory. Make changes to the path using the Set Path dialog box, and with addpath
and rmpath
functions--choose whichever suits your needs. You can use this method if you do not have write access to $matlabroot/toolbox/local
.
There are some disadvantages to this method. You might inadvertently remove directories supplied by The MathWorks from the path. When you update to a new version of MATLAB, you cannot use the pathdef.m
file in the startup directory, but must delete it and create a new version. If you run MATLAB on both Windows and UNIX platforms, you need to maintain a separate pathdef.m
file for each.
Saving the Path in $matlabroot/toolbox/local
If you have write access to $matlabroot/toolbox/local
, make and save changes to the path using the Set Path dialog box, and with addpath
and rmpath
functions--choose whichever suits your needs.
There are some disadvantages to this method. You cannot maintain this file when you update to a new version of MATLAB, but will need to use the new default pathdef.m
and make changes to it. If you run MATLAB on both Windows and UNIX platforms, you need to maintain a separate pathdef.m
file for each.
Saving Settings to the Path | Recovering from Problems with the Search Path |
© 1994-2005 The MathWorks, Inc.