Main Content

removeLabel

Remove label from project

Description

removeLabel(proj,projectFiles,categoryName,labelName) detaches the specified label in the specified category from the files projectFiles.

example

removeLabel(proj,projectFiles,labelName) detaches the specified label from the files projectFiles. Use this syntax only if the label name is unique in the project.

example

removeLabel(proj,projectFiles,labelDefinition) detaches the label specified by the label definition object labelDefinition from the files projectFiles. Before you can remove the label, you need to get the label definition object from the file.Label property or by using findLabel.

removeLabel(category,labelName) removes the specified label from the specified category of labels in the currently loaded project. Use this syntax to remove a label from a category by name.

example

removeLabel(fileObject,categoryName,labelName) removes the specified label in the specified category from the specified file. Use this syntax to remove a label from a file by name.

removeLabel(fileObject,labelDefinition) deletes the label specified by the label definition object labelDefinition. Before you can remove the label, you need to get the label definition object from the file.Label property or by using findLabel.

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;

Query the existing labels for a file.

filename = fullfile("source","timesTableGame.m");
myfile = findFiles(proj,filename,OutputFormat="ProjectFile");
existingLabel =  myfile.Labels
existingLabel = 

  Label with properties:

            File: "C:\myProjects\examples\TimesTableApp\source\timesTableGame.m"
        DataType: 'none'
            Data: []
            Name: "Design"
    CategoryName: "Classification"

Detach the label from the file. The file now has no labels.

removeLabel(proj,myfile,existingLabel)
myfile
myfile = 

  ProjectFile with properties:

                   Path: "C:\myProjects\examples\TimesTableApp\source\timesTableGame.m"
                 Labels: [1×0 matlab.project.Label]
               Revision: "286043ae7ee557100902fb645a6c97eca5d50472"
    SourceControlStatus: Unmodified

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

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

Examine the first 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");

Delete the new label from the project.

removeLabel(cat,"Future");

Input Arguments

collapse all

Project, specified as a matlab.project.Project object.

Category of labels, specified as a Category object. Get a Category object from the proj.Categories property or by using findCategory.

Name of the label to remove, specified as a character vector, a string scalar, or a LabelDefinition object returned by the file.Label property or the findLabel function.

Project files to label, specified as a cell array of character vectors, a string array, or an array of ProjectFile objects.

Object of the file to remove the label from, specified as a ProjectFile object. You can get the ProjectFile object by examining the project Files property (proj.Files) or by using findFiles to find a file by name.

Name of the category that contains the label to remove, specified as a character vector, string scalar, or Category object.

Name of the label to remove, specified as a LabelDefinition object returned by the file.Label property or findLabel.

Version History

Introduced in R2019a

expand all