フィルターのクリア

How to count and plot the number of points in a grid?

22 ビュー (過去 30 日間)
Bhanu Pratap Singh
Bhanu Pratap Singh 2021 年 2 月 17 日
コメント済み: Just Manuel 2021 年 3 月 2 日
I have a huge data set of more than 19,00,000 points. By point I meant x and y. I am creating a 20*20 minor grid in my plot. I would like to count the number of points that fall in a single grid cell and plot/print the number (of points) in the grid itself in an another plot. I tried to look at hist3() and histcounts2() functions but, couldn't get a hold of it.
Please find attached the picture of the figure.
Please help. Thanks in advance.
  3 件のコメント
Bhanu Pratap Singh
Bhanu Pratap Singh 2021 年 2 月 18 日
編集済み: Bhanu Pratap Singh 2021 年 2 月 18 日
Currently, this is what I am doing. I am not sure, whether I am getting the right output or not. I am using MATLAB R2018a.
%% Read the file into a matrix
C = textscan(fopen('offsets-1.txt'), '%d%d%d%d%f%f%f%f%f%f%f');
% C{6}, C{7} = Easting, northing of Shot Points
% C{8}, C{9} = Easting, northing of Receiver Points
% C{10}, C{11} = Easting, northing of Midpoints Points
sx = C{6}; sy = C{7};
rx = C{6}; ry = C{7};
mx = C{6}; my = C{7};
xedges = min(rx):20:max(rx);
yedges = min(ry):20:max(ry);
nbins_x = length(xedges); nbins_y = length(yedges);
histogram2(mx, my, 'XBinEdges', xedges, 'YBinEdges', yedges, 'DisplayStyle','tile', 'ShowEmptyBins', 'off');
colorbar;
Rik
Rik 2021 年 2 月 18 日
Why do you think there might be something wrong? I'm on mobile so I can't run your code, but nothing jumps out at me from your code.

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

採用された回答

Just Manuel
Just Manuel 2021 年 2 月 17 日
Hehe, being curious and doing the stuff mathworks slaps in your face sometimes pays off ;) (I mean the community treasure hunt)
This brought me across this approach to what you want to do:
Have fun watching the Video ;)
Cheers
Manuel
  1 件のコメント
Just Manuel
Just Manuel 2021 年 3 月 2 日
Please accept the answer, if it was of use to you.
Cheers
Manuel

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by