i have a matrix A of size 523418*2, i want to delete repeating pair?? as i explained below. any help??
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
M.Prasanna kumar
am 5 Feb. 2019
Kommentiert: Guillaume
am 5 Feb. 2019
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
0 Kommentare
Akzeptierte Antwort
Guillaume
am 5 Feb. 2019
[~, tokeep] = unique(sort(a, 2), 'rows', 'stable'); %stable optional if you don't care about the ROW ordering
result = a(tokeep, :)
2 Kommentare
Guillaume
am 5 Feb. 2019
~ means don't care about that output (the first one). We only keep about the second output, which is the index of the unique rows (the one you want to keep).
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Data Workflows finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!