计算几个子区域中每个子区域的点数

时间:2014-09-22 15:27:45

标签: matlab process grid point poisson

根据某个点过程我有点分布在一个正方形上,可能是泊松点过程。我想将正方形划分为更小的正方形并计算每个子正方形中的点数。有可能通过内置函数在Matlab中轻松实现吗?

1 个答案:

答案 0 :(得分:0)

正如Nras所说,内置命令hist3完全符合您的要求。为了证明它的用途,我生成了具有均匀分布的极半径和极角的点:

n = 100000;
r = rand(n,1);
theta = 2*pi*rand(n,1);
points = [r.*cos(theta), r.*sin(theta)];
hist3(points,[15,15]);    % [15,15] is the number of bins in each direction

图形输出如下。如果您想要实际计数而不是图片,请用

替换最后一个命令
counts = hist3(points,[15,15]);

hist3