# pulsesep

Separation between bilevel waveform pulses

## Syntax

```S = pulsesep(X)S = pulsesep(X,FS)S = pulsesep(X,T)[S,INITCROSS] = pulsesep(...)[S,INITCROSS,FINALCROSS] = pulsesep(...)[S,INITCROSS,FINALCROSS,NEXTCROSS] = pulsesep(...)[S,INITCROSS,FINALCROSS,NEXTCROSS,MIDLEV] = pulsesep(...)[S,INITCROSS,FINALCROSS,NEXTCROSS,MIDLEV] = pulsesep(...,Name,Value)pulsesep(...)```

## Description

`S = pulsesep(X)` returns the differences, `S`, between the mid-reference level instants of the final negative-going transitions of every positive-polarity pulse and the next positive-going transition. `X` is a bilevel waveform. To determine the transitions that compose each pulse, `pulsesep` estimates the state levels of `X` by a histogram method. `pulsesep` 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 `pulsesep` uses interpolation to determine the mid-reference level instants, `S` may contain values that do not correspond to sampling instants of the bilevel waveform, `X`.

`S = pulsesep(X,FS)` specifies the sampling rate, `FS`, in Hz as a positive scalar. The first time instant corresponds to t=0. Because `pulsesep` uses interpolation to determine the mid-reference level instants, `S` may contain values that do not correspond to sampling instants of the bilevel waveform, `X`.

`S = pulsesep(X,T)` specifies the sampling instants, `T`, in a vector equal in length to `X`. Because `pulsesep` uses interpolation to determine the mid-reference level instants, `S` may contain values that do not correspond to sampling instants of the bilevel waveform, `X`.

```[S,INITCROSS] = pulsesep(...)``` returns the mid-reference level instants, `INITCROSS`, of the first positive-polarity transitions.

```[S,INITCROSS,FINALCROSS] = pulsesep(...)``` returns the mid-reference level instants, `FINALCROSS`, of the final transition of each pulse.

```[S,INITCROSS,FINALCROSS,NEXTCROSS] = pulsesep(...)``` returns the mid-reference level instants, `NEXTCROSS`, of the next detected transition after each pulse.

```[S,INITCROSS,FINALCROSS,NEXTCROSS,MIDLEV] = pulsesep(...)``` returns the mid-reference level, `MIDLEV`.

```[S,INITCROSS,FINALCROSS,NEXTCROSS,MIDLEV] = pulsesep(...,Name,Value)``` returns the pulse separations with additional options specified by one or more `Name,Value` pair arguments.

`pulsesep(...)` plots the signal and darkens the regions between each pulse where pulse separation 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.

## Input Arguments

 `X` Bilevel waveform. If the waveform, `X`, does not contain at least two transitions, `pulsesep` outputs an empty matrix. `FS` Sample rate in hertz. `T` Vector of sample instants. The length of `T` must equal the length of the bilevel waveform, `X`.

### Name-Value Pair Arguments

 `'MidPercentReferenceLevel'` Mid-reference level as a percentage of the waveform amplitude. Default: `50` `'Polarity'` Pulse polarity. Specify the polarity as `'positive'` or `'negative'`. If you specify `'positive'`, `pulsesep` looks for pulses with positive-going (positive polarity) initial transitions. If you specify `'negative'`, `pulsesep` looks for pulses with negative-going (negative polarity) initial transitions. See Pulse Polarity. Default: `'positive'` `'StateLevels'` Low- and high-state levels. `StateLevels` is a 1-by-2 real-valued vector. The first element is the low-state level. The second element is the high-state level. If you do not specify low- and high-state levels, `pulsesep` estimates the state levels from the input waveform using the histogram method. `'Tolerance'` Tolerance levels (lower- and upper-state boundaries) expressed as a percentage. See State-Level Tolerances. Default: `2`

## Output Arguments

 `S` Pulse separations in seconds. The pulse separation is defined as the time between the mid-reference level instants of the final transition of one pulse and the initial transition of the next pulse. See Pulse Separation. `INITCROSS` Mid-reference level instants of initial transition. `FINALCROSS` Mid-reference level instants of final transition. `NEXTCROSS` Mid-reference level instants of the initial transition after the final transition of the preceding pulse. `MIDLEV` Waveform value that corresponds to the mid-reference level.

## Examples

collapse all

### Pulse Separation in Bilevel Waveform

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

```load('pulseex.mat','x','t') s = pulsesep(x,t) ```
```s = 3.5014e-06 ```

Plot the waveform and annotate the pulse separation.

```pulsesep(x,t); ```

### Mid-Reference Level Instants Defining Pulse Separation

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

```load('pulseex.mat','x','t') [~,~,finalcross,nextcross] = pulsesep(x,t) ```
```finalcross = 4.6256e-06 nextcross = 8.1270e-06 ```

Return the pulse separation. Annotate the mid-reference level instants on a plot of the data.

```pulsesep(x,t) ```
```ans = 3.5014e-06 ```

expand all

### Mid-Reference Level

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

${S}_{1}+\frac{1}{2}\left({S}_{2}-{S}_{1}\right)$

### 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

### Pulse Polarity

If the pulse has an initial positive-going transition, the pulse has positive polarity. The following 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 pulse has an initial negative-going transition, the pulse has negative polarity. The following 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

Each state level can have an associated lower- and upper-state boundary. These state boundaries are defined as the state level plus or minus a scalar multiple of the difference between the high state and 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 α% tolerance region for the low state is defined as

${S}_{1}±\frac{\alpha }{100}\left({S}_{2}-{S}_{1}\right)$

where S1 is the low-state level and S2 is the high-state level. Replace the first term in the equation with S2 to obtain the α% tolerance region for the high state.

The following figure illustrates lower and upper 2% state boundaries (tolerance regions) for a positive-polarity bilevel waveform. The red dashed lines indicate the estimated state levels.

### Pulse Separation

Pulse separation is the time difference between the mid-reference level instant of the final transition of one pulse and the mid-reference level instant of the initial transition of the next pulse. The following figure illustrates pulse separation.

## References

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