Main Content

Estimate delay(s) between signals

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 *M*by-_{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}If you wish to treat a row vector

`x`

of length*L*as comprising one sample from_{X}*L*different channels, you need to append one or more rows of zeros to_{X}`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`

:Each column of

`xm`

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

and`0`

.xm = [1 1 1 1; 0 0 0 0];

The `finddelay`

function uses the `xcorr`

function to
determine the cross-correlation between each pair of signals at all possible lags specified by
the user. The normalized cross-correlation between each pair of signals is then calculated.
The estimated delay is given by the negative of the lag for which the normalized
cross-correlation has the largest absolute value.

If more than one lag leads to the largest absolute value of the cross-correlation, such as in the case of periodic signals, the delay is chosen as the negative of the smallest (in absolute value) of such lags.

Pairs of signals need not be exact delayed copies of each other. However, the estimated delay has a useful meaning only if there is sufficient correlation between at least one pair of the delayed signals.

`alignsignals`

| `dtw`

| `edr`

| `findsignal`

| `xcorr`