alignsignals
Align two signals by delaying earliest signal
Syntax
Description
[
estimates
the delay, D, between the two input signals, Xa
,Ya
]
= alignsignals(X
,Y
)X
and Y
,
and returns the aligned signals, Xa
and Ya
.
If
Y
is delayed with respect toX
, then D is positive andX
is delayed by D samples.If
Y
is advanced with respect toX
, then D is negative andY
is delayed by –D samples.
Delays in X
or Y
can
be introduced by prepending zeros.
[
keeps
the lengths of the aligned signals, Xa
,Ya
]
= alignsignals(X
,Y
,maxlag
,'truncate')Xa
and Ya
,
the same as those of the input signals, X
and Y
,
respectively.
If the estimated delay, D, is positive, then D zeros are prepended to
X
and the last D samples ofX
are truncated.If the estimated delay, D, is negative, then –D zeros are prepended to
Y
and the last –D samples ofY
are truncated.
Notes
X
and Y
are row or
column vectors of length LX and LY,
respectively.
If D ≥ LX, then
Xa
consists of LX zeros. All samples ofX
are lost.If –D ≥ LY, then
Ya
consists of LY zeros. All samples ofY
are lost.
To avoid assigning a specific value to maxlag
when
using the 'truncate'
option, set maxlag
to []
.
Examples
Input Arguments
Output Arguments
Algorithms
You can find the theory on delay estimation in the specification of the
finddelay
function (see Algorithms).The
alignsignals
function uses the estimated delay D to delay the earliest signal such that the two signals have the same starting point.As specified for the
finddelay
function, the pair of signals need not be exact delayed copies of each other. However, the signals can be successfully aligned only if there is sufficient correlation between them. For more information on estimating covariance and correlation functions, see [1].If your signals have features such as pulses or transitions, you can align them more effectively using measurement functions instead of correlation. For an example, see Align Two Bilevel Waveforms.
References
[1] Orfanidis, Sophocles J. Optimum Signal Processing. An Introduction. 2nd Ed. Englewood Cliffs, NJ: Prentice-Hall, 1996.
Extended Capabilities
See Also
dtw
| edr
| finddelay
| findsignal
| xcorr