Name
Size
Bytes Class
Attributes
state
150x1
16200 cell
The variable state is a cell array of character vectors requiring 17,400 bytes of memory.
Convert state to a categorical array.
state = categorical(state);
Display the discrete categories in the variable state.
categories(state)
ans = 3x1 cell
{'CA'}
{'MA'}
{'NY'}
state contains 150 elements, but only three distinct categories.
Display information about the variable state.
whos state
Name
Size
Bytes Class
Attributes
state
150x1
476 categorical
There is a significant reduction in the memory required to store the variable.
See Also
categorical | categories
Related Examples
•
“Create Categorical Arrays” on page 8-2
•
“Convert Text in Table Variables to Categorical” on page 8-6
•
“Compare Categorical Array Elements” on page 8-16
•
“Access Data Using Categorical Arrays” on page 8-24
More About
•
“Ordinal Categorical Arrays” on page 8-36
Advantages of Using Categorical Arrays
8-35
Size
Bytes Class
Attributes
state
150x1
16200 cell
The variable state is a cell array of character vectors requiring 17,400 bytes of memory.
Convert state to a categorical array.
state = categorical(state);
Display the discrete categories in the variable state.
categories(state)
ans = 3x1 cell
{'CA'}
{'MA'}
{'NY'}
state contains 150 elements, but only three distinct categories.
Display information about the variable state.
whos state
Name
Size
Bytes Class
Attributes
state
150x1
476 categorical
There is a significant reduction in the memory required to store the variable.
See Also
categorical | categories
Related Examples
•
“Create Categorical Arrays” on page 8-2
•
“Convert Text in Table Variables to Categorical” on page 8-6
•
“Compare Categorical Array Elements” on page 8-16
•
“Access Data Using Categorical Arrays” on page 8-24
More About
•
“Ordinal Categorical Arrays” on page 8-36
Advantages of Using Categorical Arrays
8-35
