MATLAB Function Reference | ![]() ![]() |
View or change 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
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 newpath
, where newpath
is a string array of directories.
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 Search Path, How Functions Work", and How MATLAB Determines Which Method to Call.
Note
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 may be overwritten when you install a new version of MATLAB. Also note that locations of files in $matlabroot/toolbox directories are loaded and cached in memory at the beginning of each MATLAB session to improve performance. If you edit and save files in $matlabroot/toolbox directories using the Editor, run clear functions to ensure that the updated files are used. If you save files to $matlabroot/toolbox directories using 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 Development Environment documentation. |
Examples
To add a new directory to the search path on Windows,
To add a new directory to the search path on UNIX,
See Also
addpath
, cd
, dir
, genpath
, matlabroot
, partialpath
, pathtool
, rehash
, rmpath
, what
![]() | Patch Properties | path2rc | ![]() |