findCategory - Find project category of labels - MATLAB (original) (raw)
Main Content
Find project category of labels
Syntax
Description
[categories](#mw%5F4e4ff36f-d65b-45ff-b292-8d2e6af92d87) = findCategory([proj](#mw%5F9c257e98-71ad-4741-bf99-7e17713bfa97),[categoryNames](#mw%5F9d799578-db9a-40db-9a2f-0dba8fb51c0e))
create category objects for the specified categories in the specified project. You need to get a category before you can use the addLabel or removeLabel 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;
Use findCategory
to get a category of labels by name.
category = findCategory(proj,"Classification")
category =
Category with properties:
Name: "Classification"
SingleValued: 1
DataType: "none"
LabelDefinitions: [1×7 matlab.project.LabelDefinition]
Alternatively, you can get categories by index. Get the first category.
ans =
Category with properties:
Name: "Classification"
SingleValued: 1
DataType: "none"
LabelDefinitions: [1×7 matlab.project.LabelDefinition]
Find out what you can do with the category.
Methods for class matlab.project.Category:
createLabel findLabel removeLabel
Input Arguments
Project, specified as a matlab.project.Project
object. Use currentProject to create a project object from the currently loaded project.
Name of the categories to get, specified as a string array or a cell array of character vectors.
Output Arguments
Categories of labels, returned as an array of Category
objects that you can query or modify. If the specified category is not found, the function returns an empty array.
Version History
Introduced in R2019a
Starting in R2025a, the findCategory
function supports creating multiple category objects in one step.