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

    %% Specify Number of Histogram Bins
% Plot a bivariate histogram of 1,000 pairs of random numbers sorted into
% 25 equally spaced bins, using 5 bins in each dimension.

% Copyright 2015 The MathWorks, Inc.

x = randn(1000,1);
y = randn(1000,1);
nbins = 5;
h = histogram2(x,y,nbins)

%%
% Find the resulting bin counts.
counts = h.Values