# corrmtx

Data matrix for autocorrelation matrix estimation

## Syntax

```X = corrmtx(x,m) X = corrmtx(x,m,'method') [X,R] = corrmtx(...) ```

## Description

`X = corrmtx(x,m)` returns an (n + `m`)-by-(`m` + 1) rectangular Toeplitz matrix `X`, such that `X'X` is a (biased) estimate of the autocorrelation matrix for the length-n data vector `x`. `m` must be a positive integer strictly smaller than the length of the input `x`.

`X = corrmtx(x,m,'method')` computes the matrix `X` according to the method specified by `'method'`:

• `'autocorrelation'`: (default) `X` is the (n + `m`)-by-(`m` + 1) rectangular Toeplitz matrix that generates an autocorrelation estimate for the length-n data vector `x`, derived using prewindowed and postwindowed data, based on an `m`th-order prediction error model.

• `'prewindowed'`: `X` is the n-by-(`m` + 1) rectangular Toeplitz matrix that generates an autocorrelation estimate for the length-n data vector `x`, derived using prewindowed data, based on an `m`th-order prediction error model.

• `'postwindowed'`: `X` is the n-by-(`m` + 1) rectangular Toeplitz matrix that generates an autocorrelation estimate for the length-n data vector `x`, derived using postwindowed data, based on an `m`th-order prediction error model.

• `'covariance'`: `X` is the (n – `m`)-by-(`m` + 1) rectangular Toeplitz matrix that generates an autocorrelation estimate for the length-n data vector `x`, derived using nonwindowed data, based on an `m`th-order prediction error model.

• `'modified'`: `X` is the 2(n – `m`)-by-(`m` + 1) modified rectangular Toeplitz matrix that generates an autocorrelation estimate for the length-n data vector `x`, derived using forward and backward prediction error estimates, based on an `m`th-order prediction error model.

`[X,R] = corrmtx(...)` also returns the (`m` + 1)-by-(`m` + 1) autocorrelation matrix estimate `R`, calculated as `X'*X`.

## Examples

collapse all

Generate a signal composed of three complex exponentials embedded in white Gaussian noise. Compute the data and autocorrelation matrices using the `'modified'` method.

```n = 0:99; s = exp(i*pi/2*n)+2*exp(i*pi/4*n)+exp(i*pi/3*n)+randn(1,100); m = 12; [X,R] = corrmtx(s,m,'modified');```

Plot the real and imaginary parts of the autocorrelation matrix.

```[A,B] = ndgrid(1:m+1); subplot(2,1,1) plot3(A,B,real(R)) title('Re(R)') subplot(2,1,2) plot3(A,B,imag(R)) title('Im(R)')``` ## Algorithms

The Toeplitz data matrix computed by `corrmtx` depends on the method you select. The matrix determined by the autocorrelation (default) method is given by the following matrix.

`$X=\left[\begin{array}{ccc}x\left(1\right)& \cdots & 0\\ ⋮& \ddots & ⋮\\ x\left(m+1\right)& \cdots & x\left(1\right)\\ ⋮& \ddots & ⋮\\ x\left(n-m\right)& \cdots & x\left(m+1\right)\\ ⋮& \ddots & ⋮\\ x\left(n\right)& \cdots & x\left(n-m\right)\\ ⋮& \ddots & ⋮\\ 0& \cdots & x\left(n\right)\end{array}\right]$`

In this matrix, m is the same as the input argument `m` to `corrmtx`, and n is `length(x)`. Variations of this matrix are used to return the output `X` of `corrmtx` for each method:

• `'autocorrelation'` — (default) `X` = X, above.

• `'prewindowed'``X` is the n-by-(m + 1) submatrix of X whose first row is [x(1) … 0] and whose last row is [x(n) … x(n – m)].

• `'postwindowed'``X` is the n-by-(m + 1) submatrix of X whose first row is [x(m + 1) … x(1)] and whose last row is [0 … x(n)]

• `'covariance'``X` is the (n – m)-by-(m + 1) submatrix of X whose first row is [x(m + 1) … x(1)] and whose last row is [x(n) … x(n – m)].

• `'modified'``X` is the 2(n – m)-by-(m + 1) matrix Xmod shown below.

`${X}_{\mathrm{mod}}=\left[\begin{array}{ccc}x\left(m+1\right)& \cdots & x\left(1\right)\\ ⋮& \ddots & ⋮\\ x\left(n-m\right)& \cdots & x\left(m+1\right)\\ ⋮& \ddots & ⋮\\ x\left(n\right)& \cdots & x\left(n-m\right)\\ {x}^{\ast }\left(1\right)& \cdots & {x}^{\ast }\left(m+1\right)\\ ⋮& ⋰& ⋮\\ {x}^{\ast }\left(m+1\right)& \cdots & {x}^{\ast }\left(n-m\right)\\ ⋮& ⋰& ⋮\\ {x}^{\ast }\left(n-m\right)& \cdots & {x}^{\ast }\left(n\right)\end{array}\right]$`

 Marple, S. Lawrence. Digital Spectral Analysis. Englewood Cliffs, NJ: Prentice-Hall, 1987.