Contenido principal

currentProject

R2026b

Get current project

Description

proj = currentProject gets the currently open project, and returns a project object proj that you can use to manipulate the project programmatically. When the currently open project is running a shortcut, startup file, or shutdown file for a referenced project, currentProject returns the object for the referenced project instead. If no project is open, MATLAB® displays an error. To programmatically check if any project is loaded, use matlab.project.rootProject instead. See Check if Project Is Loaded.

For more information about working with projects programmatically, see Create and Edit Projects Programmatically.

example

Examples

collapse all

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

openExample("matlab/TimesTableProjectExample")
proj = 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: ""

Output Arguments

collapse all

Project, returned as a matlab.project.Project object. Use the matlab.project.Project to programmatically manipulate the currently open project.

Version History

Introduced in R2019a