addPath - Add folder to project path - MATLAB (original) (raw)

Main Content

Add folder to project path

Syntax

Description

[folderonpath](#mw%5Fde56e0ab-47df-474c-920e-c9d5b8813f9a) = addPath([proj](#mw%5F97980b29-d13b-4f1b-a84a-7e4007fb18aa),[folders](#mw%5F55bc55d4-2649-4457-90fe-6a5b25e4c41d)) 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.

Then, add the new folder to the project path.

newfolderonpath = addPath(proj,newfolder);

Input Arguments

collapse all

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 ofPathFolder 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

Starting in R2025a, the addPath function supports adding multiple folders to the project path at the same time.