Note: This page has been translated by MathWorks. Click here to see

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

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

Cross-correlation

`r = xcorr(x,y)`

`r = xcorr(x)`

`r = xcorr(___,maxlag)`

`r = xcorr(___,scaleopt)`

```
[r,lags]
= xcorr(___)
```

returns the cross-correlation
of two discrete-time sequences. Cross-correlation measures the similarity between a vector
`r`

= xcorr(`x`

,`y`

)`x`

and shifted (lagged) copies of a vector `y`

as
a function of the lag. If `x`

and `y`

have different
lengths, the function appends zeros to the end of the shorter vector so it has the same
length as the other.

`r = xcorr(___,`

limits the
lag range from `maxlag`

)`-maxlag`

to `maxlag`

for either of
the previous syntaxes.

[1] Buck, John R., Michael M. Daniel,
and Andrew C. Singer. *Computer Explorations in Signals and Systems Using
MATLAB ^{®}*. 2nd Edition. Upper Saddle River, NJ: Prentice Hall,
2002.

[2] Stoica, Petre, and Randolph Moses.
*Spectral Analysis of Signals*. Upper Saddle River, NJ: Prentice Hall,
2005.