Documentation

findLabel

(Not recommended) Get project file label

simulinkprojectis not recommended. UsecurrentProjectoropenProjectinstead. For more information, seeCompatibility Considerations.

Description

example

label= findLabel(file,categoryName,labelName)returns the label and its attached data for the labellabelNamein the categorycategoryNamethat is attached to the specifiedfileor files. Use this syntax when you know the label name and category.

example

label= findLabel(file,labelDefinition)返回文件的标签和t的附加数据he label name and category specified bylabelDefinition. Use this syntax if you previously got alabelDefinitionby accessing aLabelsproperty, e.g., using a command likemyfile.Labels(1).

example

label= findLabel(category,labelName)returns the label definition of the label in this category specified bylabelName. Returns an empty array if the label is not found.

Examples

collapse all

Find all project files with a particular label.

Open the airframe project and create a project object.

sldemo_slproject_airframe; proj = simulinkproject;

Get the list of project files.

files = proj.Files;

Loop through each file. If the file has the extension.m, attach the labelUtility.

forfileIndex = 1:numel(files) file = files(fileIndex); [~, ~, fileExtension] = fileparts(file.Path);ifstrcmp(fileExtension,'.m') addLabel(file,'Classification','Utility');endend

Find all the files with the labelUtilityand add them to a list returned inutility_files_to_review.

utility_files_to_review = {};forjj=1:numel(files) this_file = files(jj); label = findLabel(this_file,'Classification','Utility');if( ~isempty(label))% This is a file labeled 'Utility'. Add to the% list of utility files.utility_files_to_review = [utility_files_to_review; this_file];endend

Open the airframe project and create a project object.

sldemo_slproject_airframe; proj = simulinkproject;

Get a particular file by name.

myfile = findFile(proj,'models/AnalogControl.slx');

Get a label by name.

label = findLabel(myfile,'Classification','Design');

Alternatively, examine theLabelsproperty of the file to get an array of Label objects, one for each label attached to the file.

labels = myfile.Labels

Index into the Labels property to get the label attached to the particular file.

labeldefinition = myfile.Labels(1)

After you get the label definition from the Labels property, you can use it withfindLabel.

label = findLabel(myfile,labeldefinition);

Open the airframe project and create a project object.

sldemo_slproject_airframe; proj = simulinkproject;

Get a category.

category = proj.Categories(1)
category = Category with properties: Name: 'Classification' DataType: 'none' LabelDefinitions: [1x8 slproject.LabelDefinition]

Get a label definition.

ld = findLabel(category,'Design')
ld = LabelDefinition with properties: Name: 'Design' CategoryName: 'Classification'

Input Arguments

collapse all

File to search the labels of, specified as a file object or an array of file objects. You can get the file object by examining the project’s Files property (proj.Files), or usefindFileto get a file by name. The file must be in the project.

Name of the parent category for the label, specified as a character vector.

Name of the label to get, specified as a character vector.

Name of the label to get, specified as a label definition object returned by thefile.Labelproperty.

Category of labels, specified as a category object. Get a category object from theproj.Categoriesproperty or by usingfindCategory.

Output Arguments

collapse all

Label, returned as a label object.

Compatibility Considerations

expand all

Not recommended starting in R2019a

Introduced in R2013a