You are not using accumarray in the solution provided to your previous question. The first parameter iu is the index vector, and the second parameter should be a vector of values โโof the same length. Here you specify the matrix as the second parameter, which actually has twice as many values โโas the indices in iu .
What you need to do to make it work is to create an index vector for both the second column and the third column (they are the same index, and not by chance!) And specify the corresponding column vector of values, like this:
[U, ix, iu] = unique(A(:,1)); vals = reshape(A(:, 2:end).', [], 1); %'// Columnize values subs = reshape(iu(:, ones(size(A, 2) - 1, 1)).', [], 1); %'// Replicate indices r = accumarray(subs, vals, [], @(x){x'});
This solution is generalized to any number of columns that you want to pass to accumarray .
source share