Here is an example: we build a fake data set:
>> data = [sort(randi(3,10,1)), rand(10,5)]
data =
1.0000 0.9727 0.6504 0.8675 0.9329 0.2748
1.0000 0.9217 0.1238 0.1572 0.7492 0.7884
1.0000 0.7864 0.9880 0.6371 0.8526 0.8418
1.0000 0.2187 0.6194 0.9931 0.9952 0.9586
2.0000 0.1218 0.9761 0.8390 0.6048 0.2233
2.0000 0.5117 0.0724 0.9759 0.2118 0.7046
3.0000 0.6800 0.3582 0.4349 0.8793 0.8167
3.0000 0.8622 0.4866 0.7729 0.8863 0.8443
3.0000 0.6063 0.8812 0.5100 0.6926 0.9223
3.0000 0.7486 0.0681 0.4883 0.6132 0.4820
and we group it this way:
>> groups = splitapply( @(x){x(:,2:end)}, data, data(:,1) )
groups =
3×1 cell array
{4×5 double}
{2×5 double}
{4×5 double}
Now groups is a cell array that we can index using the group ID:
>> groups{1}
ans =
0.9727 0.6504 0.8675 0.9329 0.2748
0.9217 0.1238 0.1572 0.7492 0.7884
0.7864 0.9880 0.6371 0.8526 0.8418
0.2187 0.6194 0.9931 0.9952 0.9586
>> groups{2}
ans =
0.1218 0.9761 0.8390 0.6048 0.2233
0.5117 0.0724 0.9759 0.2118 0.7046
>> groups{3}
ans =
0.6800 0.3582 0.4349 0.8793 0.8167
0.8622 0.4866 0.7729 0.8863 0.8443
0.6063 0.8812 0.5100 0.6926 0.9223
0.7486 0.0681 0.4883 0.6132 0.4820