How can I delete the repeated values and keep just a row of each one?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
DS
am 18 Feb. 2019
Beantwortet: Geoff Hayes
am 18 Feb. 2019
I have this matrix
[3 11 43;
3 17 41;
3 41 17;
3 43 11;
11 3 43;
11 43 3;
17 3 41;
17 41 3;
41 3 17;
41 17 3;
43 3 11;
43 11 3 ]
The result should be something like this [ 3 11 43; 3 17 41 ]
OBS. I tried unique() and it didn't work as I want.
0 Kommentare
Akzeptierte Antwort
Geoff Hayes
am 18 Feb. 2019
DS - you could try
unique(sort(A,2), 'rows')
where A is the matrix that you have defined above. This could be inefficient though especially as your A gets larger. With this code, we sort all the columns for each row of A and then calll unique with rows so that each row is treated as a "single entity". See unique values in array for details.
0 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays 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!