Bilevel waveform pulse width
specifies additional options using one or more
W = pulsewidth(___,
pulsewidth(___) plots the signal and darkens the regions of
each pulse where the function computes the pulse width. The function marks the location of the
midcrossings and their associated reference level. The function also plots the state levels and
their associated lower and upper boundaries.
Compute the pulse width of a bilevel waveform sampled at 4 MHz.
load('pulseex.mat','x','t') w = pulsewidth(x,t)
w = 1.5016e-06
Plot the waveform and annotate the pulse width.
Compute the initial and final transition occurrences for a bilevel waveform sampled at 4 MHz.
load('pulseex.mat','x','t'); fs = 4e6; [w,initcross,finalcross] = pulsewidth(x,fs);
Plot the result, annotated with the transition occurrences.
pulsewidth(x,fs); ax = gca; ax.XTick = [initcross finalcross];
Specify the state levels for the bilevel waveform instead of estimating the levels from the data. Specify the low-state level as 0 and the high-state level as 5.
load('pulseex.mat','x','t') fs = 4e6; [w,initcross,finalcross] = pulsewidth(x,fs,'StateLevels',[0 5]);
Plot the result annotated with the transition occurrences.
pulsewidth(x,fs,'StateLevels',[0 5]); ax = gca; ax.XTick = [initcross finalcross];
x— Bilevel waveform
Bilevel waveform, specified as a real-valued vector.
fs— Sample rate
Sample rate in hertz, specified as a real positive scalar.
t— Sample instants
Sample instants, specified as a vector. The length of
T must equal
the length of the bilevel waveform
comma-separated pairs of
the argument name and
Value is the corresponding value.
Name must appear inside quotes. You can specify several name and value
pair arguments in any order as
'StateLevels',[0 5]specifies a low-state level of 0 and a high-state level of 5.
MidPercentReferenceLevel— Midreference level
50(default) | real-valued scalar
Midreference level as a percentage of the waveform amplitude, specified as a real-valued scalar. For more information, see Midreference Level.
Polarity— Pulse polarity
Pulse polarity, specified as
'negative'. If you specify
'positive', the function
looks for pulses with positive-going (positive polarity) initial transitions. If you specify
pulsewidth function looks for
pulses with negative-going (negative polarity) initial transitions. For more information, see
StateLevels— Low- and high-state levels
Low- and high-state levels, specified as a 1-by-2 real-valued vector. The first element
is the low-state level, and the second element is the high-state level. If you do not specify
low- and high-state levels, the
pulsewidth function estimates the state
levels from the input waveform using the histogram method. For a detailed description of the
histogram method, see State-Level Estimation.
Tolerance— Tolerance levels
2(default) | real-valued scalar
Tolerance levels (lower- and upper-state boundaries) expressed as a percentage, specified as a real-valued scalar. For more information, see State-Level Tolerances.
w— Pulse widths
Pulse widths in seconds, returned as a vector. The pulse width is the time difference between the initial and final transitions of a pulse. The times of the initial and final transitions are referred to as transition occurrence instants in .
pulsewidth function uses interpolation to determine
the midreference level instants,
w might contain values that do not
correspond to sampling instants of the bilevel waveform
initcross— Midreference level instants of initial transition
Midreference level instants of the initial transition of each pulse, returned as a column vector.
finalcross— Midreference level instants of final transition
Midreference level instants of the final transition of each pulse, returned as a column vector.
midlev— Waveform value
Waveform value corresponding to the midreference level, returned as a scalar.
To determine the transitions, the
function estimates the low- and high-state levels of input
x by using a
histogram method with these steps.
Determine the minimum and maximum amplitudes of the data.
For the specified number of histogram bins, determine the bin width, which is the ratio of the amplitude range to the number of bins.
Sort the data values into the histogram bins.
Identify the lowest and highest indexed histogram bins with nonzero counts.
Divide the histogram into two subhistograms.
Compute the state levels by determining the mode or mean of the upper and lower histograms.
The function identifies all regions that cross the upper-state boundary of the low state and the lower-state boundary of the high state. The low-state and high-state boundaries are expressed as the state level plus or minus a multiple of the difference between the state levels.
The midreference level in a bilevel waveform with low-state level, S1, and high-state level, S2, is
The midreference level instant is
y50% denotes the midreference level.
t50%- and t50%+ denote the two consecutive sampling instants corresponding to the waveform values that are nearest in value to y50%.
y50%- and y50%+ denote the waveform values at t50%- and t50%+.
If the pulse has a positive-going initial transition, the pulse has positive polarity. Equivalently, a positive-polarity (positive-going) pulse has a terminating state that is more positive than the originating state. This figure shows a positive-polarity pulse.
If the pulse has a negative-going initial transition, the pulse has negative polarity. Equivalently, a negative-polarity (negative-going) pulse has an originating state that is more positive than the terminating state. This figure shows a negative-polarity pulse.
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 the 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 region for the low state is defined as
where is the low-state level and is the high-state level. Replace the first term in the equation with to obtain the tolerance region for the high state.
This figure illustrates lower and upper 5% state boundaries (tolerance regions) for a positive-polarity bilevel waveform. The thick dashed lines indicate the estimated state levels.
 IEEE Standard 181. IEEE® Standard on Transitions, Pulses, and Related Waveforms (2003).