How can I remove duplicate values

1 Ansicht (letzte 30 Tage)
Luis Alves
Luis Alves am 20 Apr. 2017
Beantwortet: Walter Roberson am 21 Apr. 2017
Hi! I want remove duplicate values of array 'positions' where the corresponding value of d is lower.
Example:
[positions,d]=dsearchn(X,Y);
positions = 1 1 2 3 5 6 7 9 12 13 15 16
d= 235 386 189 67 158 266 180 92 187 191 156 194
In this case I want exclude the second position and obtain d= 235 189 67 158 266 180 92 187 191 156 194
Thanks, Appreciate the help !

Antworten (1)

Walter Roberson
Walter Roberson am 21 Apr. 2017
[~, ~, uidx] = unique(positions, 'stable');
positions(uidx)
d(uidx)

Community Treasure Hunt

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

Start Hunting!

Translated by