categories

Names of the categories of a categorical array.

Category: Language Fundamentals > Data Types

Syntax

cats = categories(C)

Returns the category names as a cell array of character vectors.

Description

The list includes every category, even those that no element currently uses. The order is the category order, which for ordinal data is the ranking. Use countcats to see how many elements fall in each one.

Input arguments

C
categorical array.

Output arguments

cats
Column cell array, one name per category, in category order.

Example

Listing categories

c = categorical({'x','y','x'});
categories(c)
Output
ans = 2×1 cell

    {'x'}
    {'y'}

See also

categorical countcats summary unique