You are here : matlab → Signal Processing → pulsewidth
# pulsewidth() - Signal Processing

### Syntax

### Example

### Output / Return Value

### Limitations

### Alternatives / See Also

### Reference

W = pulsewidth(X) returns a vector, W, containing the time differences between the mid-reference level instants of the initial and final transitions of each positive-polarity pulse in the bilevel waveform, X. To determine the transitions, pulsewidth estimates the low- and high-state levels of X by a histogram method. pulsewidth 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. See State-Level Tolerances. Because pulsewidth uses interpolation to determine the mid-reference level instants, W may contain values that do not correspond to sampling instants of the bilevel waveform, X.W = pulsewidth(X,FS) specifies the sample rate, FS, in hertz as a positive scalar. The first sample in the waveform corresponds to t=0. Because pulsewidth uses interpolation to determine the mid-reference level instants, W may contain values that do not correspond to sampling instants of the bilevel waveform, X.W = pulsewidth(X,T) specifies the sample instants, T, as a vector with the same number of elements as X. Because pulsewidth uses interpolation to determine the mid-reference level instants, W may contain values that do not correspond to sampling instants of the bilevel waveform, X.[W,INITCROSS] = pulsewidth(...) returns a column vector, INITCROSS, whose elements correspond to the mid-reference level instants of the initial transition of each pulse. [W,INITCROSS,FINALCROSS] = pulsewidth(...) returns a column vector, FINALCROSS, whose elements correspond to the mid-reference level instants of the final transition of each pulse.[W,INITCROSS,FINALCROSS,MIDLEV] = pulsewidth(...) returns the waveform value, MIDLEV, which corresponds to the mid-reference level.W = pulsewidth(...,Name,Value) returns the pulse widths with additional options specified by one or more Name,Value pair arguments.pulsewidth(...) plots the signal and darkens the regions of each pulse where pulse width is computed. It marks the location of the mid crossings, and their associated reference level. The state levels and their associated lower and upper boundaries (adjustable by the Name,Value pair with name 'Tolerance') are also plotted.

W = pulsewidth(X)W = pulsewidth(X,FS)W = pulsewidth(X,T)[W,INITCROSS] = pulsewidth(...)[W,INITCROSS,FINALCROSS] = pulsewidth(...)[W,INITCROSS,FINALCROSS,MIDLEV] = pulsewidth(...)W = pulsewidth(...,Name,Value)pulsewidth(...)

Pulse Width of Bilevel WaveformOpen This Example 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.pulsewidth(x,t); First and Second Transition Times for Bilevel WaveformOpen This Example 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 State Levels for Bilevel WaveformOpen This ExampleSpecify the state levels for the bilevel waveform instead of estimating the levels from the data. Use the 'StateLevels' name-value pair to enter 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];