Main Content

addPath

Add folder to project path

Description

folderonpath = addPath(proj,folders) adds folders to the specified project path. The folders must be in the project. The project puts the folders on the MATLAB® search path when it loads, and removes them from the path when it closes. To learn more, see Specify Project Path.

example

Examples

collapse all

Open the Times Table App project. Use currentProject to create a project object from the currently loaded project.

openExample("matlab/TimesTableProjectExample")
proj = currentProject;

Create a new folder.

 newfolder = fullfile(proj.RootFolder,"newfolder");
 mkdir(newfolder);

Add the new folder to the project.

 addFile(proj,newfolder);

Then, add the new folder to the project path.

newfolderonpath = addPath(proj,newfolder);

Input Arguments

collapse all

Project, specified as a matlab.project.Project object. Use currentProject to create a project object from the currently loaded project.

Path of the folders to add to the project path, specified as string array or as a cell array of character vectors. The folders must be within the root folder.

Output Arguments

collapse all

Folder on project path, returned as an array of PathFolder objects containing the added folders path. The project puts the folders on the MATLAB search path when it loads and removes them from the path when it closes.

Version History

Introduced in R2019a

expand all