MATLAB: I have a matrix A of size 523418*2, i want to delete repeating pair?? as i explained below. any help?

deep learningdigital image processingdigital signal processingmachine learningmathematics

a = [ 1 2 ; 2 1 ; 2 3 ; 5 2 ]
a =
1 2
2 1
2 3
5 2
i used following two logics,but neither gives my answer
>> uniqueresult = unique(sort(a,2), 'rows');
or
uniqueresult = unique(sort(a,2), 'rows','stable');
but this gives as following
uniqueresult =
1 2
2 3
2 5
but i want as
uniqueresult =
1 2
2 3
5 2

Best Answer

[~, tokeep] = unique(sort(a, 2), 'rows', 'stable'); %stable optional if you don't care about the ROW ordering
result = a(tokeep, :)