You are here : matlabSignal Processingstatelevels

# statelevels() - Signal Processing

```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.[LEVELS,HISTOGRAM,BINLEVELS]
= statelevels(...) returns the centers of the histogram
bins.statelevels(...) displays a plot of the
signal and the corresponding computed histogram.```

### Syntax

```LEVELS = statelevels(X)LEVELS = statelevels(X,NBINS)LEVELS = statelevels(X,NBINS,METHOD)[LEVELS,HISTOGRAM]
= statelevels(...)[LEVELS,HISTOGRAM,BINLEVELS]
= statelevels(...)statelevels(...)```

### Example

```Display State Levels and SubhistogramsOpen This Example
Estimate the low- and high-state levels of 2.3 V underdamped clock data. Plot the data with the estimated state levels and subhistograms.

statelevels(x);

State Levels with 100 Bins and Modes of SubhistogramsOpen This Example
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.load('clockex.mat','x','t')
levs = statelevels(x);
Plot the clock data with the lines indicating the estimated low and high-state levels.statelevels(x)

ans =

0.0027    2.3068

State Levels Using Means of SubhistogramsOpen This Example
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.load('clockex.mat','x','t')

statelevels(x,1e3,'mean')

ans =

-0.0014    2.3014

Histogram Counts and Histogram Bin CentersOpen This ExampleEstimate 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. Use four bins.load('clockex.mat','x','t')
[levs,histog,bilevs] = statelevels(x,4)

levs =

0.2427    2.0428

histog =

50
0
0
50

bilevs =

0.2427
0.8427
1.4428
2.0428

Plot the waveform and annotate the levels.statelevels(x,4);```