Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

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 character array of folder names.

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 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)

Introduced before R2006a


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

Was this topic helpful?