MATLAB Function Reference Previous page   Next Page
addpath

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

Description

addpath('directory') adds the specified directory to the top (also called front) of the current MATLAB search path. Use the full pathname for directory.

addpath('dir','dir2','dir3' ...) adds all the specified directories to the top of the path. Use the full pathname for each dir.

addpath('dir','dir2','dir3' ...'-flag') adds the specified directories to either the top or bottom of the path, depending on the value of 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

and MATLAB returns

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


Previous page  addframe addpref Next page

© 1994-2005 The MathWorks, Inc.