FUNCTION REFERENCE
xcorr
Cross-correlation and autocorrelation of real vectors.
Cross-correlation and autocorrelation of real vectors.
Syntax
r = xcorr(x)Syntax
r = xcorr(x, y)Syntax
r = xcorr(x, maxlag)Syntax
r = xcorr(x, y, maxlag)Syntax
r = xcorr(x, y, maxlag, scale)Syntax
[r, lags] = xcorr(x, maxlag, scale)The scale option can follow any form. It is 'none' (default), 'biased',
'unbiased' or 'coeff'. Let N be the larger input length. The default maxlag
is N-1; an explicit nonnegative integer gives lags from -maxlag to maxlag.
Positive lag k computes sum(x(j+k)*y(j)); samples outside either input are
zero. Unequal inputs are padded with trailing zeros and require scale 'none'.
'biased' divides by N; 'unbiased' divides by N-abs(lag) within the support
and returns zero outside it. 'coeff' divides by the product of the input
Euclidean lengths. If either input has zero energy, 'coeff' returns NaN at
every lag. With one input, y is x. A scalar second argument means maxlag;
to correlate with a scalar y, supply maxlag as a third argument.
r follows x's row or column orientation; lags is always a row.
Example
[r, lags] = xcorr([1 2 3], 1); r % 8 14 8Differences from MATLAB: only nonempty real vectors (logical also accepted);
matrix and complex inputs are not supported yet. Uses direct sums with a
256000000-operation work bound; reduce maxlag for long inputs. Output and
statement memory limits also apply. Large independent lag sums may use the
configured worker pool; small inputs stay serial.
These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.