Find unique in matrix of x,y coordinates
Mostra commenti meno recenti
Hello, I would love your help.
If I have a matrix of x,y coordinates for example:
x y
A=[ 2.5 3.5
1.2 3.5
2.2 1.2
1.2 3.5
4.0 2.2 ]
How do I find a unique of this? In the above example one instance of x,y (1.2, 3.5) will be removed?
Risposta accettata
Più risposte (2)
Image Analyst
il 19 Dic 2017
Try unique() with the 'rows' option:
uniqueRowsOfA = unique(A, 'rows')
1 Commento
Ruchi Bhatia
il 20 Dic 2017
Kaushik Lakshminarasimhan
il 19 Dic 2017
Did you try this?
[C,IA] = unique(A,'rows');
C contains all unique rows of A. IA contains the indices of the rows of A that are in C. So if you want the indices of the rows that were removed, you can use:
[nrows,~] = size(A);
notIA = setdiff(1:nrows,IA); % duplicate rows
1 Commento
Ruchi Bhatia
il 19 Dic 2017
Categorie
Scopri di più su Creating and Concatenating Matrices in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!