Find unique rows (including rows with reverse x,y) in matrix of x,y coordinates

4 vues (au cours des 30 derniers jours)
Hi, I would appreciate your comments on this problem.
I would like to extract unique coordinates for example if x=1, y=2, then this point is similar to y=2,x=1 and only one pair is kept.
x y
1 2
2 1
2 3
3 2
I have tried two approaches; A) using unique comments
[uniqueA M2 M3] = unique(data(:,[1:2]),'rows'); This found no unique row
b) a for loop which I couldn't complete
for j=1:358
clear row3
[row3,col3,v3]=find(data(:,2)==v1 & Tab_Vn_values2(:,1)==v2);
Thank you for your time
  3 commentaires
Peyman Obeidy
Peyman Obeidy le 25 Sep 2018
Thank you KSSV for always being helpful too.

Connectez-vous pour commenter.

Réponse acceptée

Bruno Luong
Bruno Luong le 25 Sep 2018
Modifié(e) : Bruno Luong le 25 Sep 2018
[~,i] = unique(sort(data(:,1:2),2),'rows')
  3 commentaires

Connectez-vous pour commenter.

Plus de réponses (0)


En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by