This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Categorical Arrays


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 and Machine Learning 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 character vectors

See Also


Related Examples

More About

Was this topic helpful?