MATLAB Function Reference | ![]() ![]() |
Control the MATLAB directory search path
Graphical Interface
As an alternative to the path
function, use the Set Path dialog box. To open it, select Set Path from the File menu in the MATLAB desktop.
Syntax
path path newpath path(path,'
newpath') path('newpath',path
) p = path(...)
Description
path
displays the current MATLAB search path. The initial search path list is defined by toolbox/local/pathdef.m
.
path newpath
changes the search path to be comprised of those directories named in the string, 'newpath'
.
appends a new directory to the current search path.path(
path
,'newpath')
path('newpath',
prepends a new directory to the current search path.path
)
p = path(...)
returns the specified path in string variable p
.
Remarks
For more information on how MATLAB uses the directory search path, see How Functions Work and How MATLAB Determines Which Method to Call.
Note
Save any M-files you create and any MATLAB-supplied M-files that you edit in a directory that is not in the MATLAB directory tree. If you keep your files in the MATLAB directory tree, they may be overwritten when you install a new version of MATLAB. Also note that locations of files in the MATLAB/toolbox directory tree are loaded and cached in memory at the beginning of each MATLAB session to improve performance. If you do save a new or edited file in the MATLAB/toolbox directory tree, restart MATLAB or use the rehash function to reload the directory and update the cache before you use the file. |
Examples
To add a new directory to the search path on Windows,
path(path,'c:tools\goodstuff')
To add a new directory to the search path on UNIX,
path(path,'/home/tools/goodstuff')
See Also
addpath
, genpath
, cd
, dir
, partialpath
, rehash
, rmpath
, what
![]() | Patch Properties | pathtool | ![]() |