# Sparsity Representation of a Signal Using the DCT Matrix

I have a signal $$\mathbf x$$, and I need to know how to obtain the matrix which is the corresponding sparsity basis $$\mathbf\Psi$$ such that $$\mathbf x = \mathbf{\Psi\theta}$$, where $$\mathbf\theta$$ is sparse. I know that the suitable basis for my signal is the DCT basis. Given the signal, how can I obtain its DCT basis using MATLAB?

• It depends on your application. If you just want to try and generate something artificial, you can for example generate a matrix of random Gaussian entries. That will work well. When using it in a practical context, it depends on which kind of signals you are working with. Then you perhaps know a priori which kind of transform sparsifies your signals or you can try dictionary learning to learn one from data. – Thomas Arildsen Jan 8 at 20:10
• I know that the suitable basis for my signal is the DCT basis. Given the signal, how can I obtain its DCT basis using matlab? @ Thomas Arildsen – Karem Adam Jan 8 at 21:42
• I get a little confused by your terminology. When you say basis, I think of the matrix corresponding to the DCT transform. The DCT transform operation itself is independent of the signal it is applied to, so I am not sure what you mean by "given the signal". Do you simply mean, how to obtain the DCT transform of your signal? – Thomas Arildsen Jan 10 at 10:28
• I think it could be helpful if you have an equation representing your setting that you can add to your question and then point out which part of the equation you are looking to determine. – Thomas Arildsen Jan 10 at 10:30
• y=Φx where x is the N×1 original signal, Φ is an M×N random sensing matrix , and y is the compressed signal. The signal x may have sparse representation in some basis:**x=Ψθ**, where θ is the sparse vector for x under the basis Ψ .Thus the model becomes: y=ΦΨθ=Ωθ I need the suitable basis Ψ for the signal x. @ Thomas Arildsen – Karem Adam Jan 10 at 19:54

If you know that your ($$N\times 1$$) signal $$\mathbf x$$ is supposed to be sparse when DCT-transformed, then your $$\mathbf\Psi$$ should be the IDCT (inverse DCT). Then your $$\mathbf\theta$$ will be in the DCT ("frequency") domain and your $$\mathbf x$$ will be in the "time" domain.

You basically have two options for implementing this:

1. If you are using this in a context where it is OK to use the DCT as a function instead of an actual matrix, this may be more efficient, as your programming environment's implementation of the DCT is most likely more efficient in terms of storage and computational complexity than explicitly doing the matrix-vector product. In this case, look for the idct function;

x = idct(theta);

2. If you must implement it with an actual matrix-vector product, you can obtain the matrix $$\mathbf\Psi$$ by transforming an identity matrix of the appropriate dimensions:

Psi = idct(eye(N));
x = Psi * theta;


Expect that operations involving Psi * theta will be slower and more memory-consuming than idct(theta).