DSP Blockset
  Go to block:
    Search    Help Desk 
Histogram    See Also

Compute the histogram (frequency distribution) of an input or sequence of inputs.

Library

Statistics, in Math Functions

Description

The Histogram block computes the frequency distribution of the elements in the input vector, or tracks the frequency distribution in a sequence of inputs over a period of time. The Running histogram parameter allows you to toggle between basic operation and running operation, which are both described below.

Basic Operation

When the Running histogram check box is not selected, the block computes the frequency distribution in the input independently at each sample time. The block sorts the elements of the input (by their absolute value) into a number of discrete bins, as specified by the Number of bins parameter, n.

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). Each bin has width

and the bin centers are located at the following values:

Input values that fall on the borders between 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 nearest bin.

At each sample time, the block outputs a length-n vector whose elements (one per bin) represent the frequency of occurrence of the binned input values. The following example illustrates the block's operation for parameter values of Bm = -10, BM = 10, and n = 5. The resulting bin width is 4.

When the Normalized check box is selected, the block scales the output so that sum(y)=1.

Note that a matrix input is sorted as a single vector, u(:).

Running Operation

When the Running histogram check box is selected, the block tracks the frequency distribution of a sequence of inputs over time. You can choose frame-based or sample-based operation by selecting (or deselecting, respectively) the Frame-based check box.

Sample-Based Operation.    When the Frame-based check box is not selected (default), the block accepts a scalar input at the In port, and adds each successive scalar input value to the histogram. The block retains past inputs in the histogram as long as the Rst input remains zero. When the block receives a nonzero scalar value at the Rst port, it resets the histogram by emptying all the bins. If you do not need to reset the running histogram during the simulation, you can delete the Rst port from the block icon by deselecting the Reset port check box.

At each sample time the block outputs a vector whose elements (one per bin) represent the frequency of occurrence of the binned input values currently in the histogram. The following example illustrates the block's operation for parameter values of Bm = -10, BM = 10, and n = 5. The resulting bin width is 4.

Note that the block has direct feedthrough, so the output histogram is updated with the new input at the same sample time that it is received.

Frame-Based Operation.    When the Frame-based check box is selected, the block accepts a length-M frame vector containing M sequential time-samples from a single channel. The elements in each successive vector input are added the histogram and retained as long as the Rst input remains zero. When the block receives a nonzero value at the Rst port, it resets the histogram by emptying all the bins.

Note
If you expect to generate code for the Histogram block's running mode using the Real-Time Workshop, you should ensure that inputs are contiguous in memory. See the Contiguous Copy block for more information.

Dialog Box

Minimum value of input
The lower boundary, Bm, of the lowest-valued bin.
Maximum value of input
The upper boundary, BM, of the highest-valued bin.
Number of bins
The number of bins, n, in the histogram.
Normalized 
Normalizes the output vector to 1. This parameter is not tunable in Simulink's external mode.
Running histogram
Selects running operation.
Reset port
Display Rst input port.
Frame-based
Selects frame-based operation.

See Also

Sort
hist (MATLAB)


[ Previous | Help Desk | Next ]