# Finding the Correlation Matrix of Wiener Filter using Matlab

I have the problem below and need to solve it using Matlab. I not a big expert in Matlab and just don't know how to implement it. Basically, it says that

$$$$R\:=\:\left[X\left(n\right)X^T\left(n\right)\right]$$$$ but just don't know how to do that in Matlab. I searched a lot on the internet and didn't find anything relevant to what am looking for. Can somebody please help me implement this. I would really appreciate it.

• R = x*x'/length(x); Oct 23 '20 at 14:32
• But how do you implement the array X in matlab? Oct 23 '20 at 16:23
• X is defined in your problem, it is a column vector. The MATLAB syntax is explained here tutorialspoint.com/matlab/matlab_vectors.htm Oct 23 '20 at 16:36
• Do you mean X is just a vector? My problem is representing X and its dependence on the shift and time index n. Oct 23 '20 at 22:16
• @Engineer Please provide an answer if you can. This would be really helpful so i can understand the thought process. Thank you Oct 23 '20 at 22:18

Here is a simple example of Wiener filter in MATLAB. First, the input data, denoted as $$\mathbf{x}(n)$$. Note that we are considering only at time instant $$n$$ and an extension for $$N$$ time samples can be made to incorporate more time domain samples by concatenating these vectors together to get a matrix $$\mathbf{X}=[ \mathbf{x}(n) \ \ \mathbf{x}(n+1) \ \ \cdots \ \mathbf{x}(n+N-1)]$$ (that is a vector for each time instant). But for the single time instant case, lets say that $$\mathbf{x}(n)$$ is IID Gaussian with some input mean and varaince, then this input vector can be generated in MATLAB as:

x = sqrt(inputVariance)*randn(10, 1) + inputMean;


The 10 comes from your problem description. Now that you have some example input data, you can go ahead and compute the correlation matrix as you defined $$\mathbf{R} = \mathbb{E}\big[ \mathbf{x}(n) \mathbf{x}(n)^H \big]$$:

R = x*x'/size(x, 2); % size(x, 2) = # of time domain samples


Since our example input data is easy to understand (Gaussian), we can know what to expect to find in the correlation matrix. We generated the input data to be uncorrelated, so the off diagonal elements should be small and the diagonal elements should be close to the variance. One useful way to look at these matrices in MATLAB is as an image using:

figure
imagesc(R)


After doing this, you might be confused though. Because you expect to see something like this:

But instead you might see something closer to the next figure. This is because you are only taking a single time domain sample! Not enough samples for the statistical properties to emerge from the correlation matrix. In fact, it is an estimate of the true correlation matrix and you can't expect an estimator to be that good with only one sample (the first image was generated by following the steps but using x = randn(10, 100) to generate 100 time domain samples).