主要内容

currentProject

R2026b

获取当前工程

描述

proj = currentProject 获取当前打开的工程,并返回工程对象 proj,您可以使用该对象以编程方式操作工程。在当前打开的工程正在为引用工程运行快捷方式、启动文件或关闭文件时,currentProject 将为引用工程返回对象。如果没有打开的工程,MATLAB® 会显示错误。要以编程方式检查是否加载了任何工程,请改用 matlab.project.rootProject。请参阅 检查工程是否已加载。

有关以编程方式处理工程的详细信息,请参阅以编程方式创建和编辑工程。

示例

示例

全部折叠

打开 Times Table App 工程并获取一个工程对象,您可以在命令行中使用该工程对象操作工程。

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: ""

输出参量

全部折叠

工程,以 matlab.project.Project 对象形式返回。使用 matlab.project.Project 以编程方式操作当前打开的工程。

版本历史记录

在 R2019a 中推出