createLabel - Create project label - MATLAB (original) (raw)

Main Content

Syntax

Description

[labelDefinitions](#mw%5Fc1da734e-7514-4efb-84cc-054b442d121d) = createLabel([category](#mw%5Febbc21a3-7661-45b9-b749-867b064e8615),[LabelNames](#mw%5F352e181e-c1ec-4b5b-bf90-bf2371a595e5)) creates new labels, in the specified category. Use this syntax if you previously got a Category object by using the findCategory function.

example

Examples

collapse all

Open the Times Table App project. Use currentProject to create a project object from the currently loaded project.

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

Get the first existing category.

cat =

Category with properties:

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

Define a new label in the category.

createLabel(cat,"Future");

Open the Times Table App project. Use currentProject to create a project object from the currently loaded project.

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

Create a new category of labels called "Engineers" which can be used to denote file ownership in a project. These labels have the char datatype for attaching character vector data.

createCategory(proj,"Engineers","char");

Get the new category by name using the findCategory function

engineersCategory = findCategory(proj,"Engineers");

Create labels in the new category.

createLabel(engineersCategory,["Tom","Harry"]);

Attach one of the new labels to a file in the project.

label = addLabel(myfile,"Engineers","Tom");

Get the label and add data.

label.Data = "Maintenance responsibility"

Label with properties:

        File: "C:\myProjects\examples\TimesTableApp\source\timesTableGame.m"
    DataType: 'char'
        Data: "Maintenance responsibility"
        Name: "Tom"
CategoryName: "Engineers"

Input Arguments

collapse all

Category for the new label, specified as a Category object. Get the Category object by accessing aCategories property, using a syntax likeproj.Categories(1), or use thefindCategory function. To create a new category, use the createCategory function.

The name of the new labels, specified as a string array or a cell array of character vectors.

Output Arguments

collapse all

Labels definition, returned as an array oflabelDefinition objects.

Tips

Version History

Introduced in R2019a

expand all

Starting in R2025a, the createLabel function supports creating multiple labels in the same category in one step.