Main Content

currentProject

获取当前工程

说明

示例

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

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

示例

全部折叠

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

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

  Project with properties:

                        Name: "Times Table App"
    SourceControlIntegration: "Git"
          RepositoryLocation: "C:\workSpace\examples\repositories\TimesTableApp"
       SourceControlMessages: [1×3 string]
                    ReadOnly: 0
                    TopLevel: 1
                Dependencies: [1×1 digraph]
                  Categories: [1×1 matlab.project.Category]
                       Files: [1×15 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]
         DefinitionFilesType: FixedPathMultiFile
                 Description: "This example project contains the source code and tests for a simple educational app. ↵↵Use the "Project Shortcuts" toolstrip tab to find ways of getting started with this project."
                  RootFolder: "C:\workSpace\examples\TimesTableApp"
       SimulinkCodeGenFolder: ""
        ProjectStartupFolder: "C:\workSpace\examples\TimesTableApp"
         SimulinkCacheFolder: ""

输出参数

全部折叠

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

版本历史记录

在 R2019a 中推出