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.StateLevels System object

Package: dsp

State-level estimation for bilevel rectangular waveform


The StateLevels object estimates the state levels of a bilevel rectangular waveform.

To estimate the state levels of a bilevel waveform:

  1. Define and set up your state-level estimation. See Construction.

  2. Call step to estimate the state levels for an input vector according to the properties of dsp.StateLevels. 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.


sl = dsp.StateLevels creates a state-level estimation System object, sl, that estimates state levels in a bilevel rectangular waveform using the histogram method with 100 bins.

sl = dsp.StateLevels('PropertyName',PropertyValue,...) returns an StateLevels System object, sl, with each specified property set to the specified value.



Minimum and maximum levels of the histogram. Specify the range of the histogram as a 2-element real–valued row vector. Signal values outside the range defined by this property are ignored. This property applies when you set the Method property to'Histogram mode' or 'Histogram mean', and either RunningStateLevels is true, or the HistogramBoundsSource property is set to 'Property'.

Default: [0 5]


Source of histogram bounds. Specify how to determine the histogram bounds as one of 'Auto' or 'Property'. When you set this property to 'Auto', the histogram bounds are determined by the minimum and maximum input values. When you set this property to 'Property', the histogram bounds are determined by the value of the HistogramBounds property. This property applies when you set the Method property to 'Histogram mode' or 'Histogram mean', and the RunningStateLevels property is false.

Default: 'Auto'


Number of bins in the histogram. Specify the number of bins in the histogram. This property applies when you set the Method property to 'Histogram mode' or 'Histogram mean'.

Default: 100


Enable histogram output. Set this property to true to output the histogram used in the computation of the state levels. This property applies when you set the Method property to 'Histogram mode' or 'Histogram mean'.

Default: false


Algorithm used to compute state levels. Specify the method used to compute state levels as one of 'Histogram mean', 'Histogram mode', or 'Peak to peak'.

Default: 'Histogram mode'


Calculation over successive calls to step. Set this property to true to enable computation of the state levels over successive calls to the step. Otherwise, compute the state levels of the current input. When you set the RunningStateLevels property to false and you are using a histogram to compute your state levels, you must set the HistogramBoundsSource property to 'Property'.


A particular level, which can be associated with an upper and lower state boundary. States are ordered from the most negative to the most positive. In a bilevel waveform, the most negative state is the low state. The most positive state is the high state.

State-Level Tolerances

Each state level can have associated lower- and upper-state boundaries. These state boundaries are defined as the state level plus or minus a scalar multiple of the difference between the high state and low state. To provide a useful tolerance region, the scalar is typically a small number such as 2/100 or 3/100. In general, the α% tolerance region for the low state is defined as


where S1 is the low-state level and S2 is the high-state level. Replace the first term in the equation with S2 to obtain the α% tolerance region for the high state.

The following figure illustrates lower and upper 2% state boundaries (tolerance regions) for a positive-polarity bilevel waveform. The estimated state levels are indicated by a dashed red line.


plotPlot signal, state levels, and histogram
resetReset internal states of state levels object
stepEstimate state levels for bilevel rectangular waveform
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

Compute and plot the state levels of a 2.3 V underdamped noisy clock. Load the clock data in the variable, x, and the sampling instants in the variable t.

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).

load('clockex.mat', 'x', 't');

Estimate the state levels.

sl = dsp.StateLevels;
levels = sl(x);

Plot the clock data along with the estimated state levels and histograms.



The StateLevels System object uses the histogram method to estimate the states of a bilevel waveform. The histogram method is described in [1]. To summarize the method:

  1. Determine the maximum and minimum amplitudes and amplitude range of the data.

  2. For the specified number of histogram bins, determine the bin width as the ratio of the amplitude range to the number of bins.

  3. Sort the data values into the histogram bins.

  4. Identify the lowest-indexed histogram bin, ilow, and highest-indexed histogram bin, ihigh, with nonzero counts.

  5. Divide the histogram into two subhistograms. The lower-histogram bins are ilowi ≤ 1/2(ihighilow).

    The upper-histogram bins are ilow + 1/2(ihighilow) ≤ iihigh.

  6. Compute the state levels by determining the mode or mean of the lower and upper histograms.


[1] IEEE® Standard on Transitions, Pulses, and Related Waveforms, IEEE Standard 181, 2003, pp. 15–17.

Extended Capabilities

Introduced in R2012a

Was this topic helpful?