How to retrieve unique columns in a matrix ?
33 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Sai Teja Suggala
am 10 Mär. 2022
Kommentiert: Stephen23
am 25 Jan. 2023
I would like to retrieve all the unique columns in a matrix..
If my matrix =
1 -1 1 1
1 1 1 1
2 1 1 1
UniqueColumns =
1 -1 1
1 1 1
2 1 1
Thank you before hand.
0 Kommentare
Akzeptierte Antwort
Stephen23
am 10 Mär. 2022
Bearbeitet: Stephen23
am 10 Mär. 2022
A = [1,-1,1,1;1,1,1,1;2,1,1,1];
B = unique(A.','rows','stable').'
2 Kommentare
Laxmikant Sharma
am 24 Jan. 2023
Bearbeitet: Laxmikant Sharma
am 24 Jan. 2023
What if you want the indeces too?
[B idx] = unique(A.', 'rows', 'stable').'
Not working!!!
Stephen23
am 25 Jan. 2023
"What if you want the indeces too?"
A = [1,-1,1,1;1,1,1,1;2,1,1,1];
[B,idx] = unique(A.','rows','stable');
B = B.'
idx
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices 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!