You are here : matlabSignal Processingmidcross

midcross() - Signal Processing

```C = midcross(X) returns
a vector, C, of time instants where each transition
of the input signal, X,  crosses the 50% reference
level. The sample instants correspond to the indices of the input
vector. Because midcross uses interpolation to
determine the crossing instant, C may contain
values that do not correspond to sampling instants. To determine the
transitions, midcross estimates the state levels
of X by a histogram method. midcross identifies
all intervals which 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.C = midcross(X,FS) specifies
the sample rate, FS, in hertz as a positive scalar.
The first sample instant corresponds to t=0.
Because midcross uses interpolation to determine
the crossing instant, C may contain values that
do not correspond to sampling instants.C = midcross(X,T)
specifies the sample instants, T, as a vector
with the same number of elements as X. Because midcross uses
interpolation to determine the crossing instant, C may
contain values that do not correspond to sampling instants.[C,MIDLEV]
= midcross(...) returns the waveform value corresponding
to the mid-reference level. C = midcross(X,Name,Value) returns
the time instants corresponding to mid-reference level crossings with
additional options specified by one or more Name,Value pair
arguments.midcross(...) plots the signal and marks
the location of the mid-crossings (mid-reference level instants) and
the associated reference levels. midcross also
plots the state levels with upper and lower state boundaries.```

Syntax

```C = midcross(X)C = midcross(X,FS)C = midcross(X,T)[C,MIDLEV]
= midcross(...)C = midcross(X,Name,Value)midcross(...)```

Example

```Mid-Reference Level Instant of Bilevel WaveformOpen This ExampleAssuming a sampling interval of 1, compute the mid-reference level instant of a bilevel waveform. Plot the result.load('transitionex.mat','x')

midcross(x)

ans =

21.5000

The instant at which the waveform crosses the 50% reference level is 21.5. This is not a sampling instant present in the input vector. midcross uses interpolation to identify the mid-reference level crossing.Mid-Reference Level Instant with Sample RateOpen This Example
Compute the mid-reference level instant for a sampled bilevel waveform. Use the time information to determine the sample rate, which is 4 MHz.
Fs = 1/(t(2)-t(1))

Fs =

4000000

Use the sample rate to express the mid-reference level instant in seconds. Plot the waveform and annotate the result.midcross(x,Fs)

ans =

5.1250e-06

Mid-Reference Level Instant Using Sample InstantsOpen This Example
Compute the mid-reference level instant using a vector of sample times equal in length to the bilevel waveform. The sample rate is 4 MHz.

C = midcross(x,t)

C =

5.1250e-06

Annotate the result on a plot of the waveform.midcross(x,t);

Mid-Reference Level Value of Bilevel WaveformOpen This ExampleCompute the level corresponding to the mid-reference level instant.load('transitionex.mat','x','t')

[~,midlev] = midcross(x,t)

midlev =

1.1388

Annotate the result on a plot of the waveform.midcross(x,t);

Sixty Percent Reference Level Instant and Waveform ValueOpen This ExampleObtain the 60% reference level instant and value for a bilevel waveform sampled at 4 MHz.load('transitionex.mat','x','t')

[mc,Lev60] = midcross(x,t,'MidPercentReferenceLevel',60)

mc =

5.1473e-06

Lev60 =

1.3682

Annotate the result on a plot of the waveform.midcross(x,t,'MidPercentReferenceLevel',60);```