createLabel
R2026bCreate project label
Description
creates new labels, in the specified category. Use this syntax if you previously got
a labelDefinitions = createLabel(category,LabelNames)Category object by using the findCategory
function.
Examples
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 = proj.Categories(1)
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"Open the Times Table App project. Use currentProject
to create a project object from the currently loaded project.
openExample("matlab/TimesTableProjectExample")
proj = currentProject;Convert the project to use the TOML definition file type.
projRoot = proj.RootFolder
close(proj)
matlab.project.convertDefinitionFiles(projRoot.RootFolder, "Toml")
openProject(proj)Create a new category of labels named
"MyCategory".
category = proj.createCategory("MyCategory");
Create a label named "MyLabel" in the new
category.
label = category.createLabel("MyLabel");
Create a pattern to automatically label all existing and future files
inside the utilities folder with the
"MyLabel" label.
label.FilePatterns = ["utilities/*"];
Input Arguments
Category for the new label, specified as a Category
object. Get the Category object by accessing a
Categories property, using a syntax like
proj.Categories(1), or use the
findCategory 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
Labels definition, returned as an array of
labelDefinition objects.
A LabelDefinition object has these properties:
Name of the label, specified as a character vector or string scalar.
Name of the parent category of the label, specified as a character vector or string scalar.
Since R2026b
File patterns associated with the label, specified as an array of strings.
By setting this property, the software labels all the files associated with the specified pattern. For more information, see Create a Label Pattern to Automatically Label Files.
To learn more about pattern matching, see Match Files and Folders Using Patterns.
Dependencies
To set this property, the project containing this label must use the TOML definition file type.
Tips
To create and attach a new label in an existing category using a single step, use
addLabelinstead.To create a new category of labels, use
createCategoryfirst.
Version History
Introduced in R2019aYou can create file patterns to automatically label existing and new files associated with that pattern. Pattern-based labeling reduce the need to add labels individually and simplifying the configuration of your project.
Starting in R2025a, the createLabel function supports creating
multiple labels in the same category in one step.
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.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (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)