MATLAB: Extracting rows from a matrix based on values in columns

extract

Following on from this question
What if I have more than 1 column? That is, I want A to be a 6-by-4 matrix for example, so to have C{1} = 4-by-3 matrix?

Best Answer

It's much easier to do this with the newer splitapply rather than the older accumarray:
A = [[1;1;3;2;3;1], rand(6, 3)]
C = splitapply(@(rows) {rows}, A(:, 2:end), A(:, 1))