categorical

Methods

Method Reference: categorical.categories

categorical: cstr = categories (C)

List of categories in categorical array.

cstr = categories (C) returns a cell array of character vectors with the names of the categories in C.

Source Code: categorical

Example: 1

categories lists an array's categories — the full declared label set, not merely the values that happen to be present.

 C = categorical ({'M'; 'S'; 'M'}, {'S', 'M', 'L'}, 'Ordinal', true)
C =
  3x1 categorical array

    M    
    S    
    M
 categories (C)
ans =
  3x1 cell array

    {'S'}    
    {'M'}    
    {'L'}

L is a declared category (and, being ordinal, keeps its place in the order) even though no element currently takes that value.