From ControlTheoryPro.com

1 Introduction
The hist command in MATLAB generates a plot or the necessary vectors for a histogram plot. A histogram shows the distribution of data values.
2 Basic Usage
The basic usage of hist is as follows
>> [n, xout] = hist(data, nbins);
where
 nbins: # of bins for the data
 data: the data to be binned for a histogram
 n: the count of data elements in each bin
 xout: the center of the bin
When the nbins input argument is not provided then nbins defaults to 10 equally spaced bins. In this case xout can be calculated and does not need to be returned.
The hist command without output arguments plots the histogram. See below
>> hist(data) or >> hist(data, nbins)
When using the hist command with output arguments, the histogram can be plotted using the bar.
>> bar(xout, n)
3 Usage in Analysis
Often times test data will have discrete steps or discontinuities due to discrete changes in the test setup. By calculating the data mean and standard deviation in time shifting windows these discrete steps can be teased out.
In some cases the windowed mean and standard deviation can be used with a simple threshold  i.e. the windowed standard deviation is below a threshold for all time except the discrete steps. In other instances the noise in the measurement approaches a significant fraction of the step size. In this case the hist command can be very useful.
By identifying the contiguous windows with the largest standard deviations the dicrete steps can be identified. This can be done efficiently with the use of hist and sort.