Problem 60937. Dimensional FindGroupsN

The upgraded version of the built-in findgroups, supports any data type, and you can specify a split dimension, and missing values are regarded as equal valid data.
This function supports non-sortable data types (e.g. cell). For sortable data types, this function also does not guarantee that the output array is sorted.
Syntax
[G,ID]=FindGroupsN(Array,Dimension);
%Use the specified split dimension
[G,ID]=FindGroupsN(Table);
%Split the table into rows
Inputs
Array, can be a standard MATLAB array of any size and type
Table.
Dimension(1,1), split dimension, which must be a positive integer. Arrays are split into sub-arrays based on this dimension, and then they are treated as individual elements for comparison of equality. If the Table syntax is used, this parameter can only be 1.
Outputs
G(:,1), group number. Regardless of the input dimension, this parameter always returns a positive integer column vector. Unlike built-in, missing values are also given same valid group numbers.
ID, which identifies the value of each group. The sizes of all dimensions are the same as those of the input Array/Table, except that only the unique value of the Array/Table is included in the Dimension dimension, which corresponds to the group number. I.e., the ID can index G in the Dimension dimension to obtain the input Array/Table.

Solution Stats

0.0% Correct | 100.0% Incorrect
Last Solution submitted on Jul 16, 2025

Solution Comments

Show comments

Problem Recent Solvers0

No solvers yet, be the first player to solve this problem.

Suggested Problems

More from this Author14

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!