Main Content


Project object


The matlab.project.Project object represents the currently loaded project. Use the project object to query the currently loaded project and to perform various operation on it.


To create a matlab.project.Project object, use the currentProject function to get the currently open project. For example:

proj = currentProject;
If no project is currently open, use the openProject function to load an existing project. For example:
proj = openProject("C:/projects/project1/");


expand all

Project name, specified as a string.

Label categories for the project, specified as an array of Category objects.

Shortcut files for the project, specified as an array of Shortcut objects.

Project path folders that are added to the MATLAB® path, specified as an array of PathFolder objects.

Paths of referenced projects, specified as an array of ProjectReference objects.

Paths of project files, specified as an array of ProjectFile objects.

Project root folder, specified as a string. RootFolder includes the full path of the project root.

Object Functions

expand all

closeClose project
exportExport project to archive
isLoadedDetermine if project is loaded
reloadReload project
addFileAdd file or folder to project
addFolderIncludingChildFilesAdd folder and child files to project
removeFileRemove file from project
addPathAdd folder to project path
removePathRemove folder from project path
addReferenceAdd referenced project to project
removeReferenceRemove project reference
addStartupFileAdd startup file to project
addShutdownFileAdd shutdown file to project
removeStartupFileRemove startup file from project startup list
removeShutdownFileRemove shutdown file from project shutdown list
addShortcutAdd shortcut to project
removeShortcutRemove shortcut from project
addLabelAttach label to project file
createLabelCreate project label
removeLabelRemove label from project
findLabelGet project file label
createCategoryCreate category of project labels
findCategoryFind project category of labels
removeCategoryRemove project category of labels
findFileFind project file by name
listModifiedFilesList modified files in project
listRequiredFilesGet files required by specified project files
refreshSourceControlUpdate source control status of project files
updateDependenciesUpdate project dependencies


collapse all

Open the Times Table App project and use currentProject to get a project object you can manipulate at the command line.

proj = currentProject
proj = 

  Project with properties:

                        Name: "Times Table App"
    SourceControlIntegration: "Git"
          RepositoryLocation: "C:\myProjects\examples\repositories\TimesTableApp"
       SourceControlMessages: ["No remote tracking branch" "Branch status: Normal" ...
                    ReadOnly: 0
                    TopLevel: 1
                Dependencies: [1×1 digraph]
                  Categories: [1×1 matlab.project.Category]
                       Files: [1×14 matlab.project.ProjectFile]
                   Shortcuts: [1×4 matlab.project.Shortcut]
                 ProjectPath: [1×3 matlab.project.PathFolder]
           ProjectReferences: [1×0 matlab.project.ProjectReference]
                StartupFiles: [1×0 string]
               ShutdownFiles: [1×0 string]
                 Description: "This example project contains the source code and tests ...
                  RootFolder: "C:\myProjects\examples\TimesTableApp"
        ProjectStartupFolder: "C:\myProjects\examples\TimesTableApp"

Open the Times Table App project and create a project object.

proj = currentProject;

Find the functions you can execute on the project object.

Methods for class matlab.project.Project:

addFile                       listModifiedFiles             
addFolderIncludingChildFiles  listRequiredFiles             
addPath                       refreshSourceControl          
addReference                  reload                        
addShortcut                   removeCategory                
addShutdownFile               removeFile                    
addStartupFile                removePath                    
addprop                       removeReference               
close                         removeShortcut                
createCategory                removeShutdownFile            
export                        removeStartupFile             
findCategory                  updateDependencies            

Get a project object, and examine its properties.

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

proj = currentProject;

Examine the project files.

files = proj.Files
files = 

  1×14 ProjectFile array with properties:


Examine the labels of the 13th file.

ans = 

  Label with properties:

            File: "C:\myProjects\examples\TimesTableApp\utilities\runTheseTests.m"
        DataType: 'none'
            Data: []
            Name: "Design"
    CategoryName: "Classification"

Get a particular file by name.

myfile = findFile(proj,"source/timesTableGame.m")
myfile = 

  ProjectFile with properties:

                   Path: "C:\myProjects\examples\TimesTableApp\source\timesTableGame.m"
                 Labels: [1×1 matlab.project.Label]
               Revision: ""
    SourceControlStatus: Unmodified

Find out what you can do with the file.

Methods for class matlab.project.ProjectFile:

addLabel     findLabel    removeLabel  
Introduced in R2019a