加入文件夹搜索路径 -- addpath (Add folders to search path)
ddpath('folderName1','folderName2','folderName3' ...)
addpath('folderName1','folderName2','folderName3' ... flag)
addpath folderName1 folderName2 folderName3 ... -flag)
previous_path = addpath(...)
这里的flag为
'-begin' :Add specified folders to the top of the search path.
'-end' :Add specified folders to the bottom of the search path.
'-frozen' :Disables change detection for folders you add to the path, which conserves Windows change notification resources (Windows only). Typehelp changenotification in the Command Window for more information.
例子:
Add c:/matlab/myfiles to the top of the search path:
addpath('c:/matlab/myfiles')Add c:/matlab/myfiles to the end of the search path:
addpath c:/matlab/myfiles -endAdd myfiles and its subfolders to the search path:
addpath(genpath('c:/matlab/myfiles'))
On Windows, Add myfiles to the top of the search path, disable folder change notification, and display the search path before adding myfiles:
previous = addpath('c:/matlab/myfiles', '-frozen')
去除文件夹搜索路径 rmpath (Remove folders from search path)
rmpath('folderName') removes the specified folder from the search path . Use the full path forfolderName.
rmpath folderName is the command form of the syntax.
如果想把该目录下的所有子目录都添加到路径中去,也不用把所有的子目录逐一addpath,用genpath函数就可以啦:
Use genpath in conjunction with addpath to add a folder and its subfolders to the search path. Add myfiles and its subfolders to the search path:
addpath(genpath('c:/matlab/myfiles'))