How can i count the number of point in each grid?

5 ビュー (過去 30 日間)
Vamsi Krishna Vempati
Vamsi Krishna Vempati 2021 年 1 月 21 日
コメント済み: KSSV 2021 年 1 月 22 日
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.

回答 (1 件)

KSSV
KSSV 2021 年 1 月 21 日
Get each box coordinates, this box is a polygon and then use the function inpolygon. Run a loop for each box.
  2 件のコメント
Vamsi Krishna Vempati
Vamsi Krishna Vempati 2021 年 1 月 21 日
Hi,
Thank you for the answer. But I am trying to calculate the total number of points within those coordinates and not if a certain point is inside the polygon or outside of it.
KSSV
KSSV 2021 年 1 月 22 日
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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by