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.

example

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

[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.

example

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

[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.

example

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.

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

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

Mid-Reference Level

The mid-reference level in a bilevel waveform with low-state level S1 and high- state level S2 is

S1+12(S2S1)

Mid-Reference Level Instant

  • Let y50% denote the mid-reference level.

  • Let t50%- and t50%+ denote the two consecutive sampling instants corresponding to the waveform values nearest in value to y50%.

  • Let y50%- and y50%+ denote the waveform values at t50%- and t50%+.

The mid-reference level instant is

t50%=t50%+(t50%+t50%y50%+y50%)(y50%+y50%)

Pulse Polarity

If the initial transition of a pulse is positive-going, the pulse has positive polarity. This figure shows a positive-polarity pulse.

Equivalently, a positive-polarity (positive-going) pulse has a terminating state more positive than the originating state.

If the initial transition of a pulse is negative-going, the pulse has negative polarity. This figure shows a negative-polarity pulse.

Equivalently, a negative-polarity (negative-going) pulse has a originating state more positive than the terminating state.

State-Level Tolerances

You can specify lower- and upper-state boundaries for each state level. Define the boundaries 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, specify the scalar as a small number such as 2/100 or 3/100. In general, the $\alpha\%$ region for the low state is defined as

$$S_1\pm{\alpha\over{100}}(S_2-S_1),$$

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 $\alpha\%$ tolerance region for the high state.

This figure shows lower and upper 5% state boundaries (tolerance regions) for a positive-polarity bilevel waveform. The thick dashed lines indicate the estimated state levels.

References

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

Extended Capabilities

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

Version History

Introduced in R2012a