Skip to content

countcats

Count occurrences of each category.

n = countcats(A)
n = countcats(A, dim)

Returns the count of values in each category of A. Result is a numeric vector with one entry per category, in the canonical category order.

C = categorical({'a','b','a','c','a'});
countcats(C) % [3; 1; 1]
  • summary — Summary of a categorical array.
  • categories — List of category names in a categorical array.