DSP Blockset | ![]() ![]() |
Generate the histogram of an input or sequence of inputs.
Library
Description
The Histogram block computes the frequency distribution of the elements in each column of the input, or tracks the frequency distribution in a sequence of inputs over a period of time. The Running histogram parameter selects between basic operation and running operation, described below.
The block sorts the elements of each column into the number of discrete bins specified by the Number of bins parameter, n.
y = hist(u,n) % Equivalent MATLAB code
Complex inputs are sorted by their magnitudes.
The histogram value for a given bin represents the frequency of occurrence of the input values bracketed by that bin. The upper-boundary of the highest-valued bin is specified by the Maximum value of input parameter, BM, and the lower-boundary of the lowest-valued bin is specified by the Minimum value of input parameter, Bm. The bins have equal width of
Input values that fall on the border between two bins are sorted into the lower-valued bin; that is, each bin includes its upper boundary. For example, a bin of width 4 centered on the value 5 contains the input value 7, but not the input value 3. Input values greater than the Maximum value of input parameter or less than Minimum value of input parameter are sorted into the highest-valued or lowest-valued bin, respectively.
Basic Operation
When the Running histogram check box is not selected, the block computes the frequency distribution of each column in the M-by-N input u
independently at each sample time.
For convenience, length-M 1-D vector inputs and sample-based length-M row vector inputs are both treated as M-by-1 column vectors.
The output, y
, is a sample-based n-by-N matrix whose jth column is the histogram for the data in the jth column of u
. When the Normalized check box is selected, the block scales each column of the output so that sum(y(:,j))
is 1.
Running Operation
When the Running histogram check box is selected, the block computes the frequency distributions in a time-sequence of M-by-N inputs by creating N persistent histograms to which successive inputs are continuously added. For frame-based inputs, this is equivalent to a persistent histogram for each independent channel.
As in basic operation, length-M 1-D vector inputs and sample-based length-M row vector inputs are both treated as M-by-1 column vectors.
The output is a sample-based n-by-N matrix whose jth column reflects the current state of the jth histogram. The block resets the running histogram (by emptying all bins of all histograms) when the scalar input at the optional Rst
port is nonzero. (The Rst
port can be disabled by deselecting the Reset port check box.)
Example
The model below illustrates the Histogram block's basic operation for a single-channel input, u
, where
u = [0 -2 6 -12 2 5 4 3 0 4 3 -2 -3 -2 -9]'
The parameter settings for the Histogram block are:
-10
10
5
The resulting bin width is 4, as shown below.
Dialog Box
Rst
input port when selected.See Also
Sort |
DSP Blockset |
hist |
MATLAB |
![]() | From Wave File | IDCT | ![]() |