xcorr
Computes discrete auto or cross correlation
Syntax
[c, lagindex] = xcorr(x) [c, lagindex] = xcorr(x, y) [c, lagindex] = xcorr(.., maxlags) [c, lagindex] = xcorr(.., maxlags, scaling)
Parameters
- x
 a vector of real or complex floating point numbers.
- y
 a vector of real or complex floating point numbers. The default value is
x.- maxlags
 a scalar with integer value greater than 1. The default value is
n. Wherenis the maximum of thexandyvector length.- scaling
 a character string with possible value:
"biased","unbiased","coeff","none". The default value is"none".- c
 a vector of real or complex floating point numbers with same orientation as
x.- lagindex
 a row vector, containing the lags index corresponding to the
cvalues.
Description
c=xcorr(x)computes the un-normalized discrete auto correlation:
and return in
cthe sequence of auto correlation lags Ck=-n:n wherenis the length ofxxcorr(x,y)computes the un-normalized discrete cross correlation:
and return in
cthe sequence of auto correlation lags Ck=-n:n wherenis the maximum ofxandylengths.
If the maxlags argument is given
            xcorr returns in c the sequence of
            auto correlation lags Ck=-maxlags:maxlags. If
            maxlags is greater than length(x),
            the first and last values of c are zero.
The scaling argument describes how
            C(k) is normalized before being returned in
            c:
            
- "biased": 
c=C/n. - "unbiased": 
c=C./(n-(-maxlags:maxlags)). - "coeff": 
c=C/(norm(x)*norm(y)). 
![]()  | The corr function computes the "biased" covariance of
             Method: This function computes C using
              | 
Examples
t = linspace(0, 100, 2000); y = 0.8 * sin(t) + 0.8 * sin(2 * t); [c, ind] = xcorr(y, "biased"); plot(ind, c)

See also
History
| Version | Description | 
| 5.4.0 | xcorr added. | 
| Report an issue | ||
| << hank | Convolution - intercorrélation | Filtrage >> | 
