Estimate delay(s) between signals

`D = finddelay(X,Y)`

D = finddelay(...,maxlag)

`D = finddelay(X,Y)`

, where `X`

and `Y`

are
row or column vectors, returns an estimate of the delay `D`

between `X`

and `Y`

,
where `X`

serves as the reference vector. If `Y`

is
delayed with respect to `X`

, then `D`

is
positive. If `Y`

is advanced with respect to `X`

,
then `D`

is negative. Delays in `X`

and `Y`

can
be introduced by prepending zeros.

`X`

and `Y`

need not be exact
delayed copies of each other, as `finddelay(X,Y)`

returns
an estimate of the delay via cross-correlation. However this estimated
delay has a useful meaning only if there is sufficient correlation
between delayed versions of `X`

and `Y`

.
Also, if several delays are possible, as in the case of periodic signals,
the delay with the smallest absolute value is returned. In the case
that both a positive and a negative delay with the same absolute value
are possible, the positive delay is returned.

`D = finddelay(X,Y)`

, where `X`

is
a matrix of size *M _{X}*-by-

`Y`

is a
matrix of size `D`

of
estimated delays between each column of `X`

and the
corresponding column of `Y`

. With this usage the
number of columns of `X`

must be equal to the number
of columns of `Y`

(i.e., `D = finddelay(...,maxlag)`

,
uses `maxlag`

as the maximum correlation window size
used to find the estimated delay(s) between `X`

and `Y`

.
The usage of `maxlag`

is detailed in the table below.

By default, `maxlag`

is equal to max(*L _{X}*,

`X`

and `Y`

, respectively), max(`maxlag`

is
input as `[]`

, it is replaced by the default value.
If any element of `maxlag`

is negative, it is replaced
by its absolute value. If any element of `maxlag`

is
not integer-valued, or is complex, `Inf`

, or `NaN`

,
then `finddelay`

returns an error.The calculation of the vector of estimated delays, `D`

,
depends on `X`

, `Y`

, and `maxlag`

as
shown in the following table.

`maxlag` | `X` | `Y` | `D` is calculated by... |
---|---|---|---|

Integer-valued scalar | Row or column vector or matrix | Row or column vector or matrix | Cross-correlating the columns of `X` and `Y` over
a range of lags –`maxlag` :`maxlag` . |

Integer-valued row or column vector | Row or column vector of length L ≥ 1_{X} | Matrix of size M-by-_{Y}N (_{Y}M > 1, _{Y}N > 1)_{Y} | Cross-correlating `X` and column j of `Y` over
a range of lags –`maxlag` (j):`maxlag` (j),
for j = 1:N. _{Y} |

Integer-valued row or column vector | Matrix of size M-by-_{X}N (_{X}M > 1, _{X}N > 1)_{X} | Row or column vector of length L ≥ 1_{Y} | Cross-correlating column j of `X` and `Y` over
a range of lags –`maxlag` (j):`maxlag` (j),
for j = 1:N. _{X} |

Integer-valued row or column vector | Matrix of size M-by-_{X}N (_{X}M > 1, _{X}N > 1)_{X} | Matrix of size Mby-_{Y}-N (_{Y}M > 1, _{Y}N = _{Y}N > 1)_{X} | Cross-correlating column j of `X` and
column j of `Y` over a range of
lags –`maxlag` (j):`maxlag` (j),
for j = 1:N._{Y} |

`X`

as Multiple ChannelsIf you wish to treat a row vector `X`

of length *L _{X}* as
comprising one sample from

`X`

so
that it appears as a matrix. Then each column of `X`

will
be considered a channel.For example, `X = [1 1 1 1]`

is considered
a single channel comprising four samples. To treat it as four different
channels, each channel comprising one sample, define a new matrix `Xm`

:

Xm = [1 1 1 1; 0 0 0 0];

Each column of `Xm`

corresponds to a single
channel, each one containing the samples `1`

and `0`

.

`alignsignals`

| `dtw`

| `edr`

| `findsignal`

| `xcorr`

Was this topic helpful?