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?

  • $\begingroup$ 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. $\endgroup$ Jan 8, 2019 at 20:10
  • $\begingroup$ 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 $\endgroup$
    – Karem Adam
    Jan 8, 2019 at 21:42
  • $\begingroup$ 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? $\endgroup$ Jan 10, 2019 at 10:28
  • $\begingroup$ 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. $\endgroup$ Jan 10, 2019 at 10:30
  • 1
    $\begingroup$ 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 $\endgroup$
    – Karem Adam
    Jan 10, 2019 at 19:54

1 Answer 1


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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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