Remove coordiantes with less than n repeats in y coordinate

1 visualización (últimos 30 días)
Jason
Jason el 22 de Oct. de 2019
Comentada: Jason el 22 de Oct. de 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

Respuesta aceptada

Matt J
Matt J el 22 de Oct. de 2019
Editada: Matt J el 22 de Oct. de 2019
G=findgroups(y);
[C,~,idx]=histcounts(y, 1:max(G)+1);
keep=C(idx)>=n;
coords=coords(keep,:)

Más respuestas (0)

Categorías

Más información sobre Financial Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by