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.
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 it detects a reset event at the optional Rst
port, as described next.
Resetting the Running Histogram. The block resets the running histogram whenever a reset event is detected at the optional Rst
port. The reset signal rate must be a positive integer multiple of the rate of the data signal input.
To enable the Rst
port, select the Reset port parameter. The reset event is specified by the Trigger type parameter, and can be one of the following:
Rst
input does one of the following:
Rst
input does one of the following:
Rst
input is a Rising edge or Falling edge (as described above).
Rst
input is not zero.
Note When running simulations in the Simulink MultiTasking mode, sample-based reset signals have a one-sample latency, and frame-based reset signals have one frame of latency. Thus, there is a one-sample or one-frame delay between the time the block detects a reset event, and when it applies the reset. For more information on latency and the Simulink tasking modes, see Excess Algorithmic Delay (Tasking Latency) and the topic on the Simulation Parameters dialog box in the Simulink documentation. |
Example
The model below illustrates the Histogram block's basic operation for a single-channel input, u
, where
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. The rate of the reset signal must be a positive integer multiple of the rate of the data signal input. This parameter is enabled only when you set the Running histogram parameter. For more information, see Running Operation.Supported Data Types
Rst
port, which is enabled when you set the Reset port parameter.
To learn how to convert to the above data types in MATLAB and Simulink, see Supported Data Types and How to Convert to Them.
See Also
Sort |
DSP Blockset |
hist |
MATLAB |
Also see Statistics for a list of all the blocks in the Statistics library.
![]() | From Wave File | IDCT | ![]() |