This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

dsp.Histogram System object

Package: dsp

Histogram of input or sequence of inputs


The Histogram object generates a histogram for an input or a sequence of inputs.

To generate a histogram for an input or a sequence of inputs:

  1. Define and set up your histogram object. See Construction.

  2. Call step to generate the histogram for an input according to the properties of dsp.Histogram. The behavior of step is specific to each object in the toolbox.

    Note:   Starting in R2016b, instead of using the step method to perform the operation defined by the System object™, you can call the object with arguments, as if it were a function. For example, y = step(obj,x) and y = obj(x) perform equivalent operations.


hist = dsp.Histogram returns a histogram object, hist, that computes the frequency distribution of the elements in each input matrix.

hist = dsp.Histogram('PropertyName',PropertyValue, ...) returns a histogram object, hist, with each specified property set to the specified value.

hist = dsp.Histogram(MIN,MAX,NUMBINS,'PropertyName',PropertyValue,...) returns a histogram object, hist, with the LowerLimit property set to MIN, UpperLimit property set to MAX, NumBins property set to NUMBINS and other specified properties set to the specified values.



Lower boundary

Specify the lower boundary of the lowest-valued bin as a real-valued scalar. NaN and Inf are not valid values for this property. The default is 0. This property is tunable.


Upper boundary

Specify the upper boundary of the highest-valued bin as a real-valued scalar. NaN and Inf are not valid values for this property. The default is 10. This property is tunable.


Number of bins in histogram

Specify the number of bins in the histogram. The default is 11.


Specify how the histogram calculation is performed over the data as one of | All | Column |. The default is Column.


Enable output vector normalization

Specify whether the histogram object normalizes the output vector, v, so that sum(v)=1. When you set this property to true, the output vector is normalized. When you set it to false, the object supports fixed-point operations and does not use this property for normalization. The default is false.


Enable calculation over successive step method calls

Set this property to true to enable running histogram calculations for the input elements over successive calls to the step method. Set this property to false to compute a histogram for the current input. The default is false.


Enable resetting in running histogram mode

Set this property to true to enable resetting the running histogram. When you set the property to true, specify a reset input to the step method that resets the running histogram. This property applies when you set the RunningHistogram property to true. When this property is false, the histogram object does not reset. The default is false.


Reset condition for running histogram mode

Specify the event that resets the running histogram as one of | Rising edge | Falling edge | Either edge | Non-zero |. This property applies when you set the ResetInputPort property to true. The default is Non-zero

 Fixed-Point Properties


resetReset histogram bin values to zero
stepHistogram for input data
Common to All System Objects

Create System object with same property values


Expected number of inputs to a System object


Expected number of outputs of a System object


Check locked states of a System object (logical)


Allow System object property value changes


expand all

Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent step syntax. For example, myObject(x) becomes step(myObject,x).

Compute a histogram with four bins, for possible input values 1 through 4.

hist = dsp.Histogram(1,4,4);
y = hist([1 2 2 3 3 3 4 4 4 4]');

y is equal to [1; 2; 3; 4] - one ones, two twos, etc.


This object implements the algorithm, inputs, and outputs described on the Histogram block reference page. The object properties correspond to the block parameters, except:

  • The Reset port block parameter corresponds to both the ResetCondition and the ResetInputPort object properties.

  • The Find histogram over block parameter corresponds to the Dimension property of the object.

Extended Capabilities

Introduced in R2012a

Was this topic helpful?