Documentation Center

  • Trial Software
  • Product Updates

Categorical Arrays

    Note:   The nominal and ordinal array data types might be removed in a future release. To represent ordered and unordered discrete, nonnumeric data, use the MATLAB® categorical data type instead.

What Are Categorical Arrays?

Categorical arrays are Statistics Toolbox™ data types for storing categorical values. Categorical arrays store data that have a finite set of discrete levels, which might or might not have a natural order. There are two types of categorical arrays:

  • ordinal arrays store categorical values with ordered levels. For example, an ordinal variable might have levels {small, medium, large}.

  • nominal arrays store categorical values with unordered levels. For example, a nominal variable might have levels {red, blue, green}.

In experimental design, these variables are often called factors, with ordered or unordered factor levels.

Categorical arrays are convenient and memory efficient containers for storing categorical variables. In addition to storing information about which category each observation belongs to, categorical arrays store descriptive metadata including category labels and order.

Categorical arrays have associated methods that streamline common tasks such as merging categories, adding or dropping levels, and changing level labels.

Categorical Array Conversion

You can easily convert to and from categorical arrays. To create a nominal or ordinal array, use nominal or ordinal, respectively. You can convert these data types to categorical arrays:

  • Numeric array

  • Logical array

  • Character array

  • Cell array of strings

See Also


Related Examples

More About

Was this topic helpful?