Digital Signal Processing Reference
In-Depth Information
x;x [k] = s x;x [k]
s x;x :
Note that x;y [k] is an estimate of the correlation, since we are dealing with
sampled data, not the underlying processes that create this data. As you may have
guessed, these formulas come from probability and statistics. The cross-correlation
is related to variance, 2 . For more information, see Probability and Statistics for
Engineers and Scientists, Third Edition by Walpole and Myers [13].
A few examples about correlation follow. Here we have x and y, two signals that
are identical, but shifted. To compute the correlation, we use a simple approxima-
tion. First, we nd the point-for-point multiplication of x and y, with the codes
that follows.
x*y.
Notice that we use the transpose of y (otherwise, we would get an error). Also, after
the rst computation, we use a dierent range for y by specifying [y(10), y(1:9)],
which concatenates the last value for y with the rst nine values. There is no need to
nd the sum of the point-for-point multiplication with the sum( ) command, since
this is done automatically. (Remember that [a b c]transpose[d e f] = ad+be+cf,
a single value.) Finally, we divide by the number of samples. This code only works
because we have been careful to keep x and y the exact same length, and because x
and y happen to have an average of zero.
>> x = [ 0 0 1 5 1 -2 -3 -2 0 0 ];
>> y = [ 1 5 1 -2 -3 -2 0 0 0 0 ];
>> x*y./length(x)
ans =
-0.8000
>> x*[y(10), y(1:9)]./length(x)
ans =
Search WWH ::




Custom Search