Main Content

pulseperiod

Period of bilevel pulse

Description

p = pulseperiod(x) returns the difference between the mid-reference level instants of the initial transition of each positive-polarity pulse and the next positive-going transition in the bilevel waveform x. To determine the transitions for each pulse, the pulseperiod function estimates the state levels of the input waveform by a histogram method and identifies all regions which cross the upper-state boundary of the low state and the lower-state boundary of the high state.

p = pulseperiod(x,Fs) specifies the sample rate Fs.

P = pulseperiod(x,t) specifies the sampling instants t.

example

[p,initcross] = pulseperiod(___) returns the mid-reference level instants initcross of the first transition of each pulse.

[p,initcross,finalcross] = pulseperiod(___) returns the mid-reference level instants finalcross of the final transition of each pulse. You can specify an input combination from any of the previous syntaxes.

[p,initcross,finalcross,nextcross] = pulseperiod(___) returns the mid-reference level instants nextcross of the next detected transition after each pulse.

example

[p,initcross,finalcross,nextcross,midlev] = pulseperiod(___) returns the mid-reference level midlev.

[p,initcross,finalcross,nextcross,midlev] = pulseperiod(___,Name,Value) returns the pulse periods with additional options specified by one or more name-value arguments.

pulseperiod(___) plots the signal and darkens every other identified pulse. The function marks the location of the mid crossings and their associated reference level. The function also plots the state levels and their associated lower and upper boundaries. You can adjust the boundaries using the 'Tolerance' name-value argument.

example

Examples

collapse all

Compute the pulse period of a bilevel waveform with two positive-polarity transitions. The sample rate is 4 MHz.

load('pulseex.mat','x','t')

p = pulseperiod(x,t)
p = 
5.0030e-06

Annotate the pulse period on a plot of the waveform.

pulseperiod(x,t);

Figure Pulse Period Plot contains an axes object. The axes object with xlabel Time (seconds), ylabel Level (Volts) contains 10 objects of type patch, line. One or more of the lines displays its values using only markers These objects represent pulse period, signal, mid cross, upper boundary, upper state, lower boundary, mid reference, lower state.

Determine the mid-reference level instants that define the pulse period for a bilevel waveform.

load('pulseex.mat','x','t')
[~,initcross,~,nextcross] = pulseperiod(x,t)
initcross = 
3.1240e-06
nextcross = 
8.1270e-06

Output the pulse period. Mark the mid-reference level instants on a plot of the data.

pulseperiod(x,t)

Figure Pulse Period Plot contains an axes object. The axes object with xlabel Time (seconds), ylabel Level (Volts) contains 10 objects of type patch, line. One or more of the lines displays its values using only markers These objects represent pulse period, signal, mid cross, upper boundary, upper state, lower boundary, mid reference, lower state.

ans = 
5.0030e-06

Input Arguments

collapse all

Bilevel waveform, specified as a real-valued vector. If x does not contain at least two transitions, the function outputs an empty matrix. The first sample instant in x corresponds to t=0.

Sample rate, specified as a positive real scalar in hertz.

Sample instants, specified as a vector. The length of t must equal the length of the input bilevel waveform x.

Name-Value Arguments

collapse all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: p = pulseperiod(x,Fs,StateLevels=[0 5])

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: p = pulseperiod(x,Fs,'StateLevels',[0 5])

Mid-reference level as a percentage of the waveform amplitude, specified as a scalar. For more information, see Mid-Reference Level.

Pulse polarity, specified as "positive" or "negative". If you specify "positive", the function looks for pulses whose initial transition is positive-going (positive polarity). If you specify "negative", the function looks for pulses whose initial transition is negative-going (negative polarity). For more information, see Pulse Polarity

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 'StateLevels', the function estimates the state levels from the input waveform using the histogram method.

Tolerance levels (lower- and upper-state boundaries), specified as a scalar and expressed as a percentage. 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. For more information, see State-Level Tolerances.

Output Arguments

collapse all

Pulse period in seconds, returned as a vector. The pulse period is defined as the time between the mid-reference level instants of two consecutive transitions. If the function does not find two positive-polarity transitions, p is empty.

Note

Because pulseperiod uses interpolation to determine the mid-reference level instants, p may contain values that do not correspond to sampling instants of the bilevel waveform, x.

Mid-reference level instants of the initial transition, returned as a vector.

Mid-reference level instants of the final transition, returned as a vector.

Mid-reference level instants of the first pulse transition after the final transition of the preceding pulse, returned as a vector.

Waveform value that corresponds to the mid-reference level, returned as a scalar.

More About

collapse all

References

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

Extended Capabilities

expand all

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2012a