Main Content

matlab.project.currentProject

R2026b

Get project if open

Description

proj = matlab.project.currentProject returns a project object proj for the currently open project that you can use to manipulate the project programmatically. Unlike the currentProject function, If no project is open, matlab.project.currentProject does not issue an error.

example

Examples

collapse all

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

openExample("matlab/TimesTableProjectExample")
proj = matlab.project.currentProject
proj = 

  Project with properties:

   Details
                             Name: "Times Table App"
                          Summary: "This example project contains the source code and tests for a simple educational app. Use the project shortcuts to get started with this project."
                       RootFolder: "C:\WorkSpace\TimesTableProjectExample\TimesTableApp"
              DefinitionFilesType: FixedPathMultiFile
                         TopLevel: 1
         SourceControlIntegration: "Git"
               RepositoryLocation: "C:\WorkSpace\repositories\TimesTableProjectExample"

   Files
                            Files: [1×13 matlab.project.ProjectFile]
                        Shortcuts: [1×4 matlab.project.Shortcut]
                       Categories: [1×1 matlab.project.Category]
                     Dependencies: [1×1 digraph]
              DependencyCacheFile: ""

   Environment
             ProjectStartupFolder: "C:\WorkSpace\TimesTableProjectExample\TimesTableApp"
                     StartupFiles: [1×0 string]
                    ShutdownFiles: [1×0 string]
                      PathFolders: [2×1 string]
                      TestFolders: [0×1 string]
              ProjectDependencies: [1×0 matlab.project.Dependency]
                ProjectReferences: [1×0 matlab.project.ProjectReference]

   Simulink
                    StartSimulink: 0
    RefreshSimulinkCustomizations: 0
              SimulinkCacheFolder: ""
            SimulinkCodeGenFolder: ""

Close the project. Then, create a project object.

close(proj)
proj = matlab.project.currentProject
proj = 

  1×0 Project array with properties:

    Name
    Description
    RootFolder
    TopLevel
    ReadOnly
    DefinitionFilesType
    SourceControlIntegration
    RepositoryLocation
    SourceControlMessages
    Files
    Shortcuts
    Categories
    Dependencies
    StartupFiles
    ShutdownFiles
    ProjectPath
    ProjectReferences

Output Arguments

collapse all

Project, returned as a matlab.project.Project object. Use the matlab.project.Project object to programmatically manipulate the currently open project. If no project is open, the function returns an empty project object.

Version History

Introduced in R2019a