| Statistics Toolbox | Search  Help Desk |
| hist | Examples See Also |
Syntax
hist(y)hist(y,nb)hist(y,x)[n,x] = hist(y,...)
Description
hist calculates or plots histograms.
hist(y) draws a 10-bin histogram for the data in vector y. The bins are equally spaced between the minimum and maximum values in y.
hist(y,nb) draws a histogram with nb bins.
hist(y,x) draws a histogram using the bins in the vector, x.
[n,x] = hist(y), [n,x] = hist(y,nb), and [n,x] = hist(y,x) do not draw graphs, but return vectors n and x containing the frequency counts and the bin locations such that bar(x,n) plots the histogram. This is useful in situations where more control is needed over the appearance of a graph, for example, to combine a histogram into a more elaborate plot statement.
Examples
Generate bell-curve histograms from Gaussian data.x = -2.9:0.1:2.9; y = normrnd(0,1,1000,1); hist(y,x)
![]()
See Also
hist is a function in MATLAB.