MATLAB: How to delete all repeat rows

MATLABmatrixrepeat

How to delete all repeat rows?
I mean all repeat rows, like :
A=
[0 4;
2 4;
0 4;
4 8;
3 4]
How to got new_A=
[2 4;
4 8;
3 4]

Best Answer

There is probably a more efficient way, but you can use unique() to get all first occurrences. Then you can use the second output to find all removed rows, which you can use as an input to setdiff.
A=[0 4;2 4;0 4;4 8;3 4;0 4];
[B,ind]=unique(A,'stable','rows');
ind=setdiff(1:size(A,1),ind);
B=setdiff(B,A(ind,:),'rows');