# Correlation of a signal

I have one sample for a signal. This sample is a vector of length 384. I need to calculate the correlation matrix for this signal,So I need many samples for the same signal. How can i generate these samples form the given sample using Matlab?

• can you be specific about what you mean by correlation matrix. – Stanley Pawlukiewicz Oct 20 '18 at 14:13
• I mean the autocorrelation matrix of the signal – Mohamed Aly Oct 20 '18 at 15:45
• hi: you just calculate the autocorrelations using the one sample so no need for more than one. this is okay because of the ergodicity assumption that is usually made about time-series. also, note that matrix is symmetric. – mark leeds Oct 20 '18 at 16:04

The Toeplitz matrix is used to compute correlation and convolution using matrix multiplication. Below is a graphic showing how to use a Toeplitz matrix specifically to perform convolution using matrix multiplication. A cross-correlation function can also be done following the same process by simply reversing the order of the coefficients in the multiplied vector (in this case we would multiply by [h3 h2 h1] to perform correlation).

This is clearer by observing the similarity and differences in the formulas for discrete time convolution and cross-correlation:

CONVOLUTION:

$$r[n]*h[h] = \sum_{m=-\infty}^\infty r[m]h[n-m]$$

CROSS CORRELATION:

$$\rho_{rh}[n] = \sum_{m=-\infty}^\infty r[m]h[m+n]$$

The code in the blue cell in the graphic is the implementation in either Matlab or Octave. This applies to auto-correlation or cross-correlation as an alternate to using the xcorr() function directly.

The utility of doing this is clearer in the following post, where I used such an operation to help demonstrate the underlying operation of the LMS equalizer:

Compensating Loudspeaker frequency response in an audio signal