countcats
Count categorical elements by category.
📝Syntax
counts = countcats(A)
counts = countcats(A, dim)
📥Input Arguments
Parameter Description
A Input categorical array.
dim Dimension along which counts are computed. Supported values are 1 and 2.
📤Output Arguments
Parameter Description
counts Counts in category order. Undefined elements are not counted.
📄Description

countcats counts how many elements belong to each category of A.

For matrices, dim controls whether categories are counted down columns or across rows.

💡Examples
Count elements in each category.
A = categorical({'red','blue','red',''}); counts = countcats(A)
Count by row.
A = categorical({'red','blue'; 'red','red'}); counts = countcats(A, 2)
🔗See Also
categorieshistcountsisundefinedsummary
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub