Filter löschen
Filter löschen

Remove coordiantes with less than n repeats in y coordinate

1 Ansicht (letzte 30 Tage)
Jason
Jason am 22 Okt. 2019
Kommentiert: Jason am 22 Okt. 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

Akzeptierte Antwort

Matt J
Matt J am 22 Okt. 2019
Bearbeitet: Matt J am 22 Okt. 2019
G=findgroups(y);
[C,~,idx]=histcounts(y, 1:max(G)+1);
keep=C(idx)>=n;
coords=coords(keep,:)

Weitere Antworten (0)

Kategorien

Mehr zu Financial Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by