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.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Count occurrences of categorical array elements by category

`B = countcats(A)`

`B = countcats(A,dim)`

`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`

Was this topic helpful?