matlab.project.rootProject
获取根工程
说明
获取当前加载工程的根工程,并返回一个工程对象,您可以使用该对象以编程方式操作根工程。如果没有打开的工程,MATLAB® 将返回空数组。在处理引用工程时,请使用 proj
= matlab.project.rootProjectmatlab.project.rootProject
。
要获取当前具有上下文的工程,例如,如果工程正在运行引用工程的快捷方式、启动文件或关闭文件,请改用 currentProject
。
有关引用工程的详细信息,请参阅大型工程组件化
示例
获取根工程
打开 Times Table App 示例工程,并获取根工程对象以在命令行中操作该工程。
openExample("matlab/TimesTableProjectExample")
proj = matlab.project.rootProject
proj = Project with properties: Name: "Times Table App" SourceControlIntegration: "Git" RepositoryLocation: "C:\myProjects\examples\repositories\TimesTableApp" SourceControlMessages: [1×3 string] 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 for a... RootFolder: "C:\Users\myProjects\examples\TimesTableApp" ProjectStartupFolder: "C:\myProjects\examples\TimesTableApp"
检查工程文件。
files = proj.Files
files = 1×14 ProjectFile array with properties: Path Labels Revision SourceControlStatus
检查工程是否已加载
打开 Times Table App 示例工程。
openExample("matlab/TimesTableProjectExample")
检查工程是否已加载。
loaded = ~isempty(matlab.project.rootProject)
loaded = logical 1
关闭工程并再次检查。
close(matlab.project.rootProject) loaded = ~isempty(matlab.project.rootProject)
loaded = logical 0
输出参量
proj
— 工程
matlab.project.Project
对象
工程,以 matlab.project.Project
对象形式返回。使用 matlab.project.Project
对象以编程方式操作当前打开的工程。
版本历史记录
在 R2019a 中推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)