Main Content

addPath

Add folder to project path

Description

folderonpath = addPath(proj,folder) adds a folder to the specified project path. The folder must be in the project. The project puts the folder on the MATLAB® search path when it loads, and removes it 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 folder to add to the project path, specified as a character vector or string. The folder must be within the root folder.

Output Arguments

collapse all

Folder on project path, returned as a PathFolder object containing the added folder 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