xcov
Cross-covariance of two sequences, or autocovariance of one.
Category: Data Import and Analysis > Descriptive Statistics
Syntax
[c, lags] = xcov(x)
Autocovariance of x at lags from -(N-1) to N-1.
[c, lags] = xcov(x, y)
Cross-covariance of x and y.
Description
xcov is xcorr applied after the mean of each sequence has been subtracted. Removing the mean keeps a constant offset from dominating the result, so the output reflects how the fluctuations around the average relate to each other at each lag.
The autocovariance at lag 0 is N times the variance (with divisor N).
Input arguments
x, y- Numeric vectors.
Output arguments
c- Covariance values, one per lag.
lags- Lag indices.
Example
Autocovariance
xcov([1 2 3])
Output
ans = 1×5
-1 0 2 0 -1
Notes
xcov belongs to the Signal Processing Toolbox in MATLAB.