countcats
Count occurrences of categorical array elements by category
Description
B = countcats(
returns the number of elements in
each category of a categorical array. The counts are in the same order as the
categories listed by the A
)categories
function.
If
A
is a vector, thencountcats
returns the number of elements in each category.If
A
is a matrix, thencountcats
treats the columns ofA
as vectors and returns the category counts for each column ofA
.If
A
is a multidimensional array, thencountcats
acts along the first array dimension whose size does not equal1
.
To display a summary of a categorical array that shows both category names and the
number of elements in each category, use the summary
function.
Examples
Input Arguments
Tips
To find the number of undefined elements in a categorical array, you must use
summary
orisundefined
.
Extended Capabilities
Version History
Introduced in R2013b
See Also
iscategory
| ismember
| summary
| isundefined
| categories