createLabel

Define Simulink Project label

Syntax

  • createLabel(category,newLabelName) example

Description

example

createLabel(category,newLabelName) creates a new label, newLabelName, in a category. Use this syntax if you previously got a category by accessing a Categories property, e.g., using a command like proj.Categories(1).

Use addLabel instead to create and attach a new label in an existing category using a single step.

Use createCategory first if you want to make a new category of labels.

Examples

expand all

Create a New Label

Open the airframe project and create a project object.

sldemo_slproject_airframe
proj = simulinkproject;

Examine the first existing category.

cat = proj.Categories(1)
cat = 

  Category with properties:

                Name: 'Review'
            DataType: 'char'
    LabelDefinitions: [1x4 slproject.LabelDefinition]

Define a new label in the category.

createLabel(cat,'review me');

Create a New Category of Labels for File Ownership

Open the airframe project and create a project object.

sldemo_slproject_airframe
proj = simulinkproject;

Create creates 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 string data.

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

Use findCategory to get the new category.

engineersCategory = findCategory(proj,'Engineers');

Create labels in the new category.

createLabel(engineersCategory,'Tom');
createLabel(engineersCategory,'Dick');
createLabel(engineersCategory,'Harry');

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

myfile = findFile(proj,'models/AnalogControl.mdl')
addLabel(myfile,'Engineers', 'Tom');

Get the label and add data.

label = findLabel(myfile,'Engineers','Tom');
label.Data = 'Maintenance responsibility';
disp(label)
Label with properties:

            File: [1x80 char]
            Data: 'Maintenance responsibility'
        DataType: 'char'
            Name: 'Tom'
    CategoryName: 'Engineers'

Input Arguments

expand all

category — Categorycategory object

Category for the new label, specified as a category object. Get the category by accessing a Categories property, e.g. with a command like proj.Categories(1), or use findCategory. To create a new category, use createCategory.

newLabelName — The name of the new label to definestring

The name of the new label to define, specified as a string.

See Also

Functions

Was this topic helpful?