DSP Blockset    
Histogram

Generate the histogram of an input or sequence of inputs.

Library

Statistics

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

and centers located at

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:

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:

The resulting bin width is 4, as shown below.

Dialog Box

Minimum value of input
The lower boundary, Bm, of the lowest-valued bin. Tunable.
Maximum value of input
The upper boundary, BM, of the highest-valued bin. Tunable.
Number of bins
The number of bins, n, in the histogram.
Normalized
Normalizes the output vector (1-norm) when selected. Tunable.
Enables running operation when selected.
Running histogram
Set to enable the running histogram operation, and clear to enable basic histogram operation. For more information, see Basic Operation and Running Operation.
Reset port
Enables the 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.
Trigger type
The type of event that resets the running histogram. For more information, see Resetting the Running Histogram. This parameter is enabled only when you set the Reset port parameter.

Supported Data Types

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