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 LX ≥ 1 | Matrix of size MY-by-NY (MY > 1, NY > 1) | Cross-correlating X and column j of
Y over a range of lags
–maxlag (j):maxlag (j),
for
j = 1:NY.
|
Integer-valued row or column vector | Matrix of size MX-by-NX (MX > 1, NX > 1) | Row or column vector of length LY ≥ 1 | Cross-correlating column j of X and
Y over a range of lags
–maxlag (j):maxlag (j),
for
j = 1:NX.
|
Integer-valued row or column vector | Matrix of size MX-by-NX (MX > 1, NX > 1) | Matrix of size MY-by-NY (MY > 1, NY = NX > 1) | Cross-correlating column j of X and
column j of Y over a range of lags
–maxlag (j):maxlag (j),
for
j = 1:NY. |
If you wish to treat a row vector x
of length
LX as comprising one sample from
LX different channels, you need to append
one or more rows of zeros to 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