Main Content

findCategory

查找标签的工程类别

说明

示例

category = findCategory(proj,categoryName) 从指定工程中获取具有指定名称的类别。在使用 addLabelremoveLabel 函数之前,您需要获得一个类别。

示例

全部折叠

打开 Times Table App 工程。使用 currentProject 从当前加载的工程创建一个工程对象。

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

使用 findCategory 按名称获取标签类别。

category = findCategory(proj,"Classification")
category = 

  Category with properties:

                Name: "Classification"
        SingleValued: 1
            DataType: "none"
    LabelDefinitions: [1×7 matlab.project.LabelDefinition]

您也可以通过索引获取类别。获取第一个类别。

proj.Categories(1)
ans = 

  Category with properties:

                Name: "Classification"
        SingleValued: 1
            DataType: "none"
    LabelDefinitions: [1×7 matlab.project.LabelDefinition]

了解您可以使用该类别做什么。

methods(category)
Methods for class matlab.project.Category:

createLabel  findLabel    removeLabel  

输入参数

全部折叠

工程,指定为 matlab.project.Project 对象。使用 currentProject 从当前加载的工程创建一个工程对象。

要获取的类别的名称,指定为字符向量或字符串标量。

输出参量

全部折叠

标签的类别,返回可查询或修改的 Category 对象。如果找不到指定的类别,函数将返回空数组。

版本历史记录

在 R2019a 中推出