Skip to Main Content Skip to Search
Product Documentation

path - View or change search path

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_files to the search path, run my_function in my_files, then restore the previous search path:

p = path
path(p,'my_files')
my_function
path(p)

See Also

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

How To


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

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS