Add folders to search path
adds the specified folders to the top of the search path for the current MATLAB® session.
disables folder change detection for folders being added in Windows®.
Use this syntax with any of the arguments in previous syntaxes. You
'-frozen' and position in either order.
Use this syntax to conserve Windows change notification resources
(Windows only). For more information, type
help changenotification in
the Command Window.
Create a folder, add it to the top of your search path, and then save the search path for future MATLAB® sessions.
mkdir('matlab/myfiles') addpath('matlab/myfiles') savepath matlab/myfiles/pathdef.m
Create the folder
matlab/myfiles and add it to the end of the search path.
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.
On Windows®, 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.
mkdir('matlab/myfiles') oldpath = addpath('matlab/myfiles','-frozen');
folderName1,...,folderNameN— Folder names to add to search path
Folder names to add to the search path, specified as one or
more character vectors. Use the full path name for each folder. Use
add all subfolders of
position— Position on search path
Position on the search path, specified as one of the following:
Add specified folders to the top of the search path.
Add specified folders to the bottom of the search path.
oldpath— Path prior to addition of folders
Path prior to the addition of folders, returned as a character vector.
To save the newly modified search path for future MATLAB sessions,
savepath function. Alternatively,
addpath statements in a
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.