gusucode.com > datatypes 工具箱matlab源码程序 > datatypes/+matlab/+internal/+table/getGroupRows.m
function grprows = getGroupRows(group,numgroups) %GETGROUPROWS get cell array containing row indices for each group. % Copyright 2014 The MathWorks, Inc. [sgroup,sgidx] = sort(group); % presort so accumarray doesn't have to nonNaN = ~isnan(sgroup); if isempty(sgroup) || ~any(nonNaN) grprows = cell(numgroups,1); else grprows = accumarray(sgroup(nonNaN),sgidx(nonNaN),[numgroups,1],@(x){x}); end