www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/NormalizedBinCountsBivariateExample.m

    %% Normalized Bin Counts
% Distribute 1,000 pairs of random numbers into bins. Specify
% |Normalization| as |'probability'| to normalize the bin counts such that
% |sum(N(:))| is |1|. That is, each bin count represents the probability
% that an observation falls within that bin.

% Copyright 2015 The MathWorks, Inc.

x = randn(1000,1);
y = randn(1000,1);
[N,Xedges,Yedges] = histcounts2(x,y,6,'Normalization','probability')