21.2.3 Cross-correlation of two signals
The cross correlation of two complex vectors
v=[v1,…,vn] and w=[w1,…,wm] is the complex vector
z=v⋆ w (note the difference between ⋆ and the convolution operation ∗,
see Section 21.2.5)
of length N=n+m−1 given by
where
V=[v0,v1,…,vn−1, | | ] and
W=[ | | ,w0,w1,…,wm−1]
|
and V∗ denotes the complex conjugate of V.
Cross-correlation is typically used for measuring similarity between
signals.
The cross_correlation
command computes the cross correlation of two vectors.
-
cross_correlation takes two arguments:
v,w, two vectors (not necessarily the same length).
- cross_correlation(v,w) returns the cross
correlation v⋆ w.
Examples
cross_correlation([1,2],[3,4,5]) |
v:=[2,1,3,2]:; w:=[1,-1,1,2,2,1,3,2,1]:;
round(cross_correlation(v,w)) |
|
| ⎡
⎣ | 2,1,0,8,9,12,15,18,13,11,5,2 | ⎤
⎦ |
| | | | | | | | | | |
|
Observe that the cross-correlation of v and w is
peaking at position 8 with the value 18, indicating that the two
signals are best correlated when the last sample in v is
aligned with the eighth sample in w. Indeed, there is an
occurrence of v in w precisely at that point.