Installation guide
Search Path
Caution Against Saving Files in matlabroot/toolbox. Save any M-files
you create and any MathWorks supplied M-files that you edit in a directory
that is not in the
matlabroot/toolbox directory tree. If you keep your
files in
matlabroot/toolbox directories, they can be overwritten when you
install a new version of MATLAB. Also note that locations of files in the
matlabroot/toolbox directory tree are loaded and cached in m emory at the
beginning of each MATLAB session to improve performance. If you save files
to
matlabroot/toolbox dire cto rie s us ing an external editor or add or remove
in from these directories using file system operations, run
rehash toolbox
before you use the files in the current session. If you make changes to existing
files in
matlabroot/toolbox directories using an external editor, run clear
functionname
before you use the files in the current session. For more
information, see
rehash or “Toolbox Path Caching in MATLAB” on page 1-17.
Function Alternative. Use
savepath to save the current path to pathdef.m.
Locate
pathdef.m in your MATLAB startup directory to automatically use
it in future sessions. Consider using
savepath in your finish.m file. To
modify the default path upon startup, include
addpath and rmpath functions
in your
startup.m f il e. For more information, see “Modifying the Path in a
startup.m File” on page 5-31.
Using the Path in Future Sessions
TherearethreebasicwaysforMATLABtoautomaticallyuseasearchpath
you specify, each with advantages and disadvantages:
• “Modifying the Path i n a startu p.m File” on p a ge 5-31
• “Saving the Path in the MATLAB Startup Directory” on page 5-32
• “Saving the Path in matlabroot/toolbox/local” on page 5-32
For background information, see “How MATLAB Finds the Search Path,
pathdef.m” on page 5-25.
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 s tarts, i t u ses
the se arch path defined in
pathdef.m in matla broot/toolbox/local and
modifies it based on the commands in the
startup.m file.
5-31