MATLAB: Finding Duplicate rows

MATLABmatrix

I want to find duplicate rows in my Nx2 matrix regardless of order. For instance if I were to have a matrix A
[ 1 2;
2 3;
2 1;
3 5;
4 6]
I would like to be told for instance that rows 1 and 3 are the same. Is there a quick and easy way to do this?
Thank you.

Best Answer

Try this:
AA =sort(A,2);
U = unique(AA,'rows');
R = cell(size(AA,1),1);
for k = 1:size(U,1)
R{k}=find(ismember(AA ,U(k,:), 'rows'));
end
Rows=R(cell2mat(cellfun(@(x)numel(x)>=2,R,'un',0)));
celldisp(Rows)