findgroups
Find groups and return group numbers.
📝Syntax
G = findgroups(A)
[G, ID] = findgroups(A)
[G, ID1, ..., IDn] = findgroups(A1, ..., An)
📥Input Arguments
Parameter Description
A, A1, ..., An grouping variables with the same number of elements.
📤Output Arguments
Parameter Description
G group numbers; missing values map to NaN.
ID the group identifiers, one output per grouping variable.
📄Description

G = findgroups(A) returns a vector of group numbers created from the grouping variable A.

Use G with splitapply to apply a function to each group.

💡Examples
[G, id] = findgroups([10; 20; 10; 30; 20])
🔗See Also
splitapplyaccumarray
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub