I have an n-by-m rectangular matrix (n != m). What\'s the best way to find out if there are any duplicate rows in it in MATLAB? What\'s the best way to find the indices of t
You can use the functions UNIQUE and SETDIFF to accomplish this:
>> mat = [1 2 3; 4 5 6; 7 8 9; 7 8 9; 1 2 3]; %# Sample matrix
>> [newmat,index] = unique(mat,'rows','first'); %# Finds indices of unique rows
>> repeatedIndex = setdiff(1:size(mat,1),index) %# Finds indices of repeats
repeatedIndex =
4 5