Calculates the cross-correlation of time domain signal. The input signal are vectors, and the auto-correlation is the cross-correlation of the same signal, e.g., corsscorrelation(x, x).
The discrete cross-correlation is defined as:
$$(f \star g)[n] \triangleq \sum_{m=-\infty}^{\infty} \overline{f[m]} g[m+n] \quad$$
Syntax |
Description |
---|---|
crosscorrelation(f,g,[m,[scaling]]); |
Calculates the cross-correlation of vectors f and g.
m (optional): the lag, a vector of sample indices. If not provided, m = -(N-1):(N-1) with N the larger of the lengths of f & g.
scaling (optional): the scaling, users can choose one of the three options:
The function returns a vector that is the same length as m. |
Example
The following example illustrates how to find the cross-correlation of two vectors.
n = 0:15;
f = mod(n, 5);
g = sign(sin(n));
plot(n, f, g);
z = crosscorrelation(f, g);
plot(-15:15, z);
See Also