| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
As an alternative to the path function, use the Set Path dialog box.
path
path('newpath')
path(path,'newpath')
path('newpath',path)
p = path
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.
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)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.
![]() | Patch Properties | path2rc | ![]() |

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 |