1
$\begingroup$

When you are transforming a signal in to a frequency domain using both DFT and DCT, say for a function sin(x), how the spectrum will be? will both frequency values (of DCT and DFT) same? Can anyone explain the values of the frequencies for the function sin(x) (obviously the frequency should be 1/2π)

$\endgroup$
2
$\begingroup$

The DCT for a signal $x(t)$ on $[0,T]$ is roughly the same as the DFT for the function $x(|t|)$ on $[-T,T]$, that is, mirrored at the vertical axis. Since that function is even, all sine coefficients will be zero and can be removed from the result.

Now $\sin(|t|)$ is different from $\sin(t)=-\sin(-t)$ for negative $t$, so the resulting coefficients will be quite unrelated. If the sampling interval ends at $t=T=2\pi$, the DFT will only exhibit one peak around frequency $f=\frac1{2\pi}$.

But because of the kink at $t=0$ in $\sin(|t|)$, and a second at the end of the sampling interval, the DCT will exhibit a general background of size $f^{-2}$ in the coefficient for frequencies $f>0$.

$\endgroup$
1
$\begingroup$

First of all DFT produces complex outputs therefore you shall better compare its magnitude with DCT magnitude whose both input and output are real.

As you may know DCT can be exactly computed from a DFT, therefore you can find exactly what will be a DCT[k] value for any k, from the DFT[k] values of the pre-processed x[n] signal. (the converse is, possibly, wrong)

Basicly DCT is used for those processes where low frequency content will be emphasized. Such as in speech or image coding. For spectral analysis purposes however, DFT would yield a better tool and mapping its results to physical frequencies is so simple. If you have matlab, check the following code to see if their difference is significant for you:

N=128; f = 123, Fs = 1024;   % set the signal parameters  
x = sin(2* pi* f*[0:N-1]/Fs);  % create a real signal x[n]  
figure,plot(abs(fft(x,N)));  % get the first half of it, since it is symmetric  
figure,plot(abs(dct(x,N)));  % get DCT for comparison

as you can see for different values of "f" there are variations in the similarity between DCT and DFT values, however their overlall envelope is (as expected) similar.

$\endgroup$
0
$\begingroup$

Have a look at Wikipedia. There is an example image, but for DFT.

DFT vs. DCT

$\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.