How can i count the number of point in each grid?
8 views (last 30 days)
Show older comments
I have a randomly generated scatter of 5000 points and I have laid a ring grid over the scatter plot.
Could somebody help me in calculating the number of points in the grid.
I did try to use histcounts2 but that was not giving me the correct answer.
Attached is a sample image in which I am trying to find the number of points in each grid.
0 Comments
Answers (1)
KSSV
on 21 Jan 2021
Get each box coordinates, this box is a polygon and then use the function inpolygon. Run a loop for each box.
2 Comments
KSSV
on 22 Jan 2021
Won't you think if you know whether points are inside the polygon, you can count the points? Inpolygon gives you the indices of points lying inside the polygon you can count the indices and the count says how many points are they.
See Also
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!