addLabel
(Not recommended) Attach label to project file
simulinkproject
is not recommended. UsecurrentProject
oropenProject
instead. For more information, seeCompatibility Considerations.
Description
addLabel(
attaches the specified labelfile
,categoryName
,labelName
)labelName
in the categorycategoryName
to the file.
addLabel(
attaches the label with datafile
,categoryName
,labelName
,labelData
)labelData
.
Examples
Attach a Label to a Project File
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')
myfile = ProjectFile with properties: Path: 'C:\Work\temp\slexamples\airframe\models\AnalogControl.slx' Labels: [1x1 slproject.Label] Revision: '2' SourceControlStatus: Unmodified
Get theLabels
property of the file.
myfile.Labels
ans = Label with properties: File: 'C:\Work\temp\slexamples\airframe\models\AnalogControl.slx' Data: [] DataType: 'none' Name: 'Design' CategoryName: 'Classification'
Attach the label'Artifact'
to the file.
addLabel(myfile,'Classification','Artifact')
ans = Label with properties: File: 'C:\Work\temp\slexamples\airframe\models\AnalogControl.slx' Data: [] DataType: 'none' Name: 'Artifact' CategoryName: 'Classification'
Index into the Labels property to get the label attached to this file.
reviewlabel = myfile.Labels(1)
reviewlabel = Label with properties: File: 'C:\Work\temp\slexamples\airframe\models\AnalogControl.slx' Data: [] DataType: 'none' Name: 'Artifact' CategoryName: 'Classification'
Detach the new label from the file.
removeLabel(myfile,reviewlabel)
Attach a Label to a Subset of Files
Attach the'Classification'
category label'Utility'
to all files in the project that have the.m
file extension.
Open the airframe project and create a project object.
sldemo_slproject_airframe; proj = simulinkproject;
Get the list of files.
files = proj.Files;
Loop through each file. If a file has the extension.m
, attach the label'Utility'
.
forfileIndex = 1:numel(files) file = files(fileIndex); [~, ~, fileExtension] = fileparts(file.Path);ifstrcmp(fileExtension,'.m') addLabel(file,'Classification','Utility');endend
In the ProjectFilesview, theClassificationcolumn displays the labelUtility
for each.m
file in theutilities
folder.
Attach a Label and Label Data to a File
Open the airframe project and create a project object.
sldemo_slproject_airframe; proj = simulinkproject;
Create a new category'Review'
.
createCategory(proj,'Review','char');
新类别,创建一个标签'To Review'
.
reviewCategory = findCategory(proj,'Review');createLabel(reviewCategory,'To Review');
Get a particular file by name.
myfile = findFile(proj,'models/AnalogControl.slx')
myfile = ProjectFile with properties: Path: 'C:\Work\temp\slexamples\airframe\models\AnalogControl.slx' Labels: [1x1 slproject.Label] Revision: '2' SourceControlStatus: Unmodified
Attach the label'To Review'
and a character vector of label data to the file.
addLabel(myfile,'Review','To Review','Whole team design review')
Index into the Labels property to get the second label attached to this particular file, and see the label data.
myfile.Labels(2)
ans = Label with properties: File: 'C:\Work\temp\slexamples\airframe\models\AnalogControl.slx' Data: 'Whole team design review' DataType: 'char' Name: 'To Review' CategoryName: 'Review'
In the ProjectFilesview, for theAnalogControl.slx
file, theReviewcolumn displays theTo Review
label with label data.
Alternatively, you can set or change label data using the data property.
mylabel = myfile.Labels(2); mylabel.Data ='Final review';
Input Arguments
file
—File to attach label to
file object
File to attach the label to, specified as a file object. You can get the file object by examining the project’s Files property (proj.Files
), or usefindFile
to find a file by name. The file must be in the project.
categoryName
—Name of category for label
character vector
Name of the category for the label, specified as a character vector.
labelName
—Name of label
character vector|label definition object
Name of the label to attach, specified as a character vector or a label definition object returned by thefile.Label
property orfindLabel
. You can specify a new label name that does not already exist in the project.
labelData
—Data to attach to label
character vector|numeric
Data to attach to the label, specified as a character vector or numeric. Data type depends on the label definition. Get a label to examine itsDataType
property usingfile.Label
orfindLabel
.
Compatibility Considerations
金宝app仿真软件项目API不是recommended
Not recommended starting in R2019a
Starting in R2019a, instead ofsimulinkproject
and related functions, use thecurrentProject
oropenProject
functions in MATLAB®. The Simulink®project API will continue to be supported, but, after R2019a, new features might be available only if you use the new MATLAB project API. There are no plans to remove the Simulink project API at this time.
The new MATLAB project API is part of the R2019a functionality enabling you to use projects in MATLAB, with or without Simulink. You can now share projects with users who do not have Simulink.
Introduced in R2013a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
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
- 比利时(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)