MATLAB: How can i find identical rows in a matrix

table similar

I have a 158×7 matrix. I want to find if there is at least one row which is identical.

Best Answer

Use unique() to find the distinct row values. If you end up with fewer rows, there are duplicates. It'll also give you indexes of one location of each of the distinct values. All the other row indexes are your duplicates.
x = [
1 1
2 2
3 3
4 4
2 2
3 3
3 3
];
[u,I,J] = unique(x, 'rows', 'first')
hasDuplicates = size(u,1) < size(x,1)
ixDupRows = setdiff(1:size(x,1), I)
dupRowValues = x(ixDupRows,:)