categories
List categories of a categorical array.
📝Syntax
names = categories(A)
names = categories(A, 'OutputType', type)
📥Input Arguments
Parameter Description
A Input categorical array.
type Output representation: 'char', 'string', or 'categorical'.
📤Output Arguments
Parameter Description
names Category names in category order.
📄Description

categories returns the category list attached to a categorical array. Undefined elements are not categories.

The default output is a cell array of character vectors.

💡Examples
Return the category names.
A = categorical({'red','blue','red'}); names = categories(A)
Return the category names as strings.
A = categorical({'small','large'}); names = categories(A, 'OutputType', 'string')
🔗See Also
categoricaladdcatsrenamecatsreordercatsiscategory
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub