Remove coordiantes with less than n repeats in y coordinate

1 vue (au cours des 30 derniers jours)
Jason
Jason le 22 Oct 2019
Commenté : Jason le 22 Oct 2019
Hello.
I have a set of x,y coordiantes:
I want to remove all corrdinates in which there are less than 'n' repeats in the y coordinate, Im sorry, but for once, I don't know where to start.
coords=[x,y]
2.00 2.00
44.53 2.00
75.00 2.00
20.00 3.00
24.00 3.00
29.00 3.00
54.00 3.00
69.00 3.00
33.00 4.00
79.00 5.00
2.00 6.00
60.00 6.00
47.00 7.00
63.00 7.00
71.00 7.00
34.44 8.00
41.00 8.00
50.00 8.00
53.48 8.00
68.00 8.00
22.51 9.00
so if n=5, i.e. keep only coordinates in which the y value is repeated at least 5 times would give.
20.00 3.00
24.00 3.00
29.00 3.00
54.00 3.00
69.00 3.00
34.44 8.00
41.00 8.00
50.00 8.00
53.48 8.00
68.00 8.00
Thanks

Réponse acceptée

Matt J
Matt J le 22 Oct 2019
Modifié(e) : Matt J le 22 Oct 2019
G=findgroups(y);
[C,~,idx]=histcounts(y, 1:max(G)+1);
keep=C(idx)>=n;
coords=coords(keep,:)

Plus de réponses (0)

Catégories

En savoir plus sur Financial Toolbox 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