LEVELS = statelevels(X)
estimates the low- and high-state levels in the bilevel waveform, X,
using the histogram method. See Algorithms.

LEVELS = statelevels(X,NBINS) specifies
the number of bins to use in the histogram as a positive scalar. If
unspecified, NBINS defaults to 100.

LEVELS = statelevels(X,NBINS,METHOD) estimates
state levels using the mean or mode of the subhistograms. Valid entries
for METHOD are 'mean' or 'mode'. METHOD defaults
to 'mode'. See Algorithms.

[LEVELS,HISTOGRAM]
= statelevels(...) returns the histogram, HISTOGRAM,
of the values in X.

statelevels(...) displays a plot of the
signal and the corresponding computed histogram.

Input Arguments

X

Bilevel waveform. X is a real-valued row
or column vector.

NBINS

Number of histogram bins

Default: 100

METHOD

State-level estimation method in the subhistograms. METHOD is
a string indicating the statistic to use for the estimation of the
low- and high-state levels. Valid entries for METHOD are 'mode' or 'mean'.
See Algorithms.

Default: 'mode'

Output Arguments

LEVELS

Levels of low and high states. LEVELS is
a 1-by-2 row vector of state levels estimated by the histogram method.
The first element of LEVELS is the low-state
level. The second element of LEVELS is the high-state
level.

HISTOGRAM

Histogram counts (frequencies). HISTOGRAM is
a column vector with NBINS elements containing
the number of data values in each histogram bin.

BINLEVELS

Histogram bin centers. BINLEVELS is a column
vector containing the bin centers for the histogram counts in HISTOGRAM.

Estimate the low and high-state levels of 2.3
V underdamped clock data sampled at 4 MHz.

Use the default number of bins and modes of the subhistograms
to estimate the state levels. Plot the clock data with the lines indicating
the estimated low and high-state levels.

Estimate the low and high-state levels of 2.3
V underdamped clock data sampled at 4 MHz.

Use the default number of bins and means of the subhistograms
to estimate the state levels. Plot the clock data with the lines indicating
the estimated low and high-state levels.

Estimate the low- and high-state levels of
2.3 V underdamped clock data sampled at 4 MHz. Return the histogram
counts and histogram bin centers used in the histogram method.

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.

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 S_{1} is the low-state
level and S_{2} is the high-state
level. Replace the first term in the equation with S_{2} 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
red dashed lines indicate the estimated state levels.