%% Histogram of Vectors
% Generate 10,000 pairs of random numbers and create a bivariate histogram. The histogram2 function automatically chooses an appropriate number of bins to cover the range of values in x and y and show the shape of the underlying distribution.

x = randn(10000,1);
y = randn(10000,1);
h = histogram2(x,y)
xlabel('x')
ylabel('y')

%
% When you specify an output argument to the histogram2 function, it returns a histogram2 object. You can use this object to inspect the properties of the histogram, such as the number of bins or the width of the bins.
% Find the number of histogram bins in each dimension.

nXnY = h.NumBins

% Copyright 2015 The MathWorks, Inc.