Main Content

addPath

Add folder to project path

Description

example

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, seeSpecify Project Path.

Examples

collapse all

Open the Times Table App project. UsecurrentProjectto create a project object from the currently loaded project.

matlab.project.example.timesTable 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 amatlab.project.Projectobject. UsecurrentProjectto 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. Specify the path relative to the project root folder. The folder must be within the root folder.

Output Arguments

collapse all

Folder on project path, returned as aPathFolderobject 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.

Introduced in R2019a