MATLAB: How to delete repetitions of rows in a matrix

matrixsimilar rows

Suppose I have the following matrix (the one I'm working on has 1000×1000 cells, so I'll simplify things):
a=[1,2,3; 8,7,8; 1,2,3; 5,6,0; 2,5,7; 2,5,7];
I want to get rid of rows that repeat themselves, so that I have one row left from each repetition set. The desired matrix in this case would be:
a=[1,2,3; 8,7,8; 5,6,0; 2,5,7];
How do I do this?

Best Answer

  • C = unique(A,'rows')