Main Content

Count occurrences of categorical array elements by category

`B = countcats(`

returns
the number of elements in each category of the categorical array, `A`

)`A`

.

If

`A`

is a vector, then`countcats`

returns the number of elements in each category.If

`A`

is a matrix, then`countcats`

treats the columns of`A`

as vectors and returns the category counts for each column of`A`

.If

`A`

is a multidimensional array, then`countcats`

acts along the first array dimension whose size does not equal`1`

.

To find the number of undefined elements in a categorical array,

`A`

, you must use`summary`

or`isundefined`

.

`categories`

| `iscategory`

| `ismember`

| `isundefined`

| `summary`