Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

path - View or change search path

GUI Alternatives

As an alternative to the path function, use the Set Path dialog box.

Syntax

path
path('newpath')
path(path,'newpath')
path('newpath',path)
p = path

Description

path displays the MATLAB search path, which is stored in pathdef.m.

path('newpath') changes the search path to newpath, where newpath is a string array of folders.

path(path,'newpath') adds the newpath folder to the end of the search path. If newpath is already on the search path, then path(path, 'newpath') moves newpath to the end of the search path.

path('newpath',path) adds the newpath folder to the top of the search path. If newpath is already on the search path, then path('newpath', path) moves newpath to the top of the search path. To add multiple folders in one statement, instead use addpath.

p = path returns the search path to string variable p.

Examples

Display the search path:

path

MATLAB returns, for example

MATLABPATH

	H:\My Documents\MATLAB
	C:\Program Files\MATLAB\R200nn\toolbox\matlab\general
	C:\Program Files\MATLAB\R200nn\toolbox\matlab\ops
	C:\Program Files\MATLAB\R200nn\toolbox\matlab\lang
	C:\Program Files\MATLAB\R200nn\toolbox\matlab\elmat
	C:\Program Files\MATLAB\R200nn\toolbox\matlab\elfun
...

R200nn represents the folder for the MATLAB release, for example, R2009b.

Add a new folder to the search path on Microsoft Windows platforms:

path(path,'c:/tools/goodstuff')

Add a new folder to the search path on UNIX[1] platforms:

path(path,'/home/tools/goodstuff')

Temporarily add the folder my_mfiles to the search path, run my_function in my_mfiles, then restore the previous search path:

p = path
path('my_mfiles')
my_function
path(p)

See Also

addpath, cd, dir, genpath, matlabroot, pathsep, pathtool, rehash, restoredefaultpath, rmpath, savepath, startup, userpath, what

Topics in the User Guide:


[1] UNIX is a registered trademark of The Open Group in the United States and other countries.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS