I have a column vector consisting of hundreds of unit64 values where duplicates appear and are always grouped together but groups appear only once. Each element of this vector corresponds to a row in a separate 2D matrix of double values. I would like to remove the duplicates from the row vector and then remove the corresponding rows in the matrix, replacing them with a single row where each column is average the removed elements in the column, while keeping the order stable. So with data like this:
1 1 2 A= 2 3 3 1 2 3 2 3 4 3 4 5 B = 4 5 6 5 6 7 6 7 8
I would want the output to be
1.5 2.5 3.5 C = 3.5 4.5 5.5 5.5 6.5 7.5
Some combination of unique and accumarray seems to be in order but I cannot figure out how to handle the multiple coulmn part of the problem.
Best Answer