MATLAB Function Reference |
Add directories to MATLAB search path
Graphical Interface
As an alternative to the addpath
function, use the Set Path dialog box. To open it, select Set Path from the File menu in the MATLAB desktop.
Syntax
addpath('directory')
addpath('dir','dir2','dir3' ...)
addpath('dir','dir2','dir3' ...
'-flag') addpath dir1 dir2 dir3 ... -flag
Description
addpath('
adds the specified directory to the top (also called front) of the current MATLAB search path. Use the full pathname for directory')
directory
.
addpath
adds all the specified directories to the top of the path. Use the full pathname for each ('dir','dir2','dir3' ...)
dir
.
addpath(
adds the specified directories to either the top or bottom of the path, depending on the value of 'dir','dir2','dir3' ...
'-flag')
flag
.
flag Argument |
Result |
0 or begin |
Add specified directories to the top of the path |
1 or end |
Add specified directories to the bottom (also called end) of the path |
addpath dir1 dir2 dir3 ... -flag
is the unquoted form of the syntax.
Remarks
To recursively add subdirectories of your directory in addition to the directory itself, run
Use addpath
statements in your startup.m
file to use the modified path in future sessions. For details, see Modifying the Path in a startup.m File in the MATLAB Desktop Tools and Development Environment Documentation.
Examples
For the current path, viewed by typing path
,
you can add c:/matlab/mymfiles
to the front of the path by typing
Verify that the files were added to the path by typing
MATLABPATH c:\matlab\mymfiles c:\matlab\toolbox\general c:\matlab\toolbox\ops c:\matlab\toolbox\strfun
You can also use genpath
in conjunction with addpath
to add subdirectories to the path from the command line. For example, to add /control
and its subdirectories to the path, use
See Also
genpath
, path
, pathdef
, pathsep
, pathtool
, rehash
, restoredefaultpath
, rmpath
, savepath
, startup
Search Path in the MATLAB Desktop Tools and Development Environment Documentation
addframe | addpref |
© 1994-2005 The MathWorks, Inc.