%% 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.

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

%
% Find the resulting bin counts.

counts = h.Values

% Copyright 2015 The MathWorks, Inc.