1
$\begingroup$

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

\begin{equation} R\:=\:\left[X\left(n\right)X^T\left(n\right)\right] \end{equation} 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.

enter image description here

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

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: enter image description here

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).

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.