Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Align two signals by delaying earliest signal

```
[Xa,Ya]
= alignsignals(X,Y)
```

```
[Xa,Ya]
= alignsignals(X,Y,maxlag)
```

```
[Xa,Ya]
= alignsignals(X,Y,maxlag,'truncate')
```

```
[Xa,Ya,D]
= alignsignals(___)
```

`[`

estimates
the delay, `Xa`

,`Ya`

]
= alignsignals(`X`

,`Y`

)* D*, between the two input signals,

`X`

and `Y`

,
and returns the aligned signals, `Xa`

and `Ya`

.If

`Y`

is delayed with respect to`X`

, thenis positive and*D*`X`

is delayed bysamples.*D*If

`Y`

is advanced with respect to`X`

, thenis negative and*D*`Y`

is delayed by –samples.*D*

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,

, is positive, then*D*zeros are prepended to*D*`X`

and the lastsamples of*D*`X`

are truncated.If the estimated delay,

, is negative, then –*D*zeros are prepended to*D*`Y`

and the last –samples of*D*`Y`

are truncated.

If

, then*D*≥*L*_{X}`Xa`

consists ofzeros. All samples of*L*_{X}`X`

are lost.If

*–*, then*D*≥*L*_{Y}`Ya`

consists ofzeros. All samples of*L*_{Y}`Y`

are lost.

,
respectively.L_{Y} |

To avoid assigning a specific value to `maxlag`

when
using the `'truncate'`

option, set `maxlag`

to `[]`

.

You can find the theory on delay estimation in the specification of the

`finddelay`

function (see Algorithms).The

`alignsignals`

function uses the estimated delayto delay the earliest signal such that the two signals have the same starting point.*D*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].

[1] Orfanidis, Sophocles J. *Optimum
Signal Processing. An Introduction*. 2nd Ed. Englewood
Cliffs, NJ: Prentice-Hall, 1996.

`dtw`

| `edr`

| `finddelay`

| `findsignal`

| `xcorr`

Was this topic helpful?