This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

라이선스가 부여된 사용자만 번역 문서를 볼 수 있습니다. 번역 문서를 보려면 로그인하십시오.


Add folders to search path


oldpath = addpath(___)



addpath(folderName1,...,folderNameN) adds the specified folders to the top of the search path for the current MATLAB® session.


addpath(folderName1,...,folderNameN,position) adds the specified folders to the top or bottom of the search path, as specified by position.


addpath(___,'-frozen') additionally disables folder change detection for folders being added. Use this syntax with any of the arguments in previous syntaxes. You can specify '-frozen' and position in either order.


oldpath = addpath(___) additionally returns the path prior to adding the specified folders.


collapse all

Create a folder, add it to the top of your search path, and then save the search path for future MATLAB® sessions.

savepath matlab/myfiles/pathdef.m

Create the folder matlab/myfiles and add it to the end of the search path.


Add matlab/myfiles and its subfolders to the search path.

Create the folder matlab/myfiles and call genpath inside of addpath to add all subfolders of matlab/myfiles to the search path.


Create the folder matlab/myfiles. Then, add it to the top of the search path, disable folder change notification, and return the search path before adding the folder.

oldpath = addpath('matlab/myfiles','-frozen');

Input Arguments

collapse all

Folder names to add to the search path, specified as one or more character vectors. Use the full path name for each folder. Use genpath with addpath to add all subfolders of folderName.

Example: 'c:\matlab\work'

Example: '/home/user/matlab'

Example: '/home/user/matlab','/home/user/matlab/test'

Position on the search path, specified as one of the following:

Value of position



Add specified folders to the top of the search path.


Add specified folders to the bottom of the search path.

Output Arguments

collapse all

Path prior to the addition of folders, returned as a character vector.


  • To save the newly modified search path for future MATLAB sessions, use the savepath function. Alternatively, use addpath statements in a startup.m file to modify the search path programmatically at startup.

  • If you use addpath within a local function, the path change persists after program control returns from the function. That is, the scope of the path change is global.

Introduced before R2006a

Was this topic helpful?