When we perform DCT transform using matlab:

 number_of_sample_data = 100;
 f=0.1; %frequency
 fs=1; %sampling rate 
 t=0:1/fs:((number_of_sample_data-1)*1/fs); %generate 100 samples
dct_transform=dct(x); %perform discrete cosine transform
figure(1), stem(dct_transform);

this piece of code will plot the magnitude of coefficients against frequencies or something else?


Actuually, that code doesn't work without defining axis t variable, and frequency f, regarding to what that code does, is simple:

x=sin(2*pi*f*t);        %x is a sinusoidal vector of frequency f and length t;
dct_transform=dct(x);   %dct_transform is a vector containing the unitary discrete transform of x
figure(1), plot(dct_transform); %plots the the unitary discrete transform of the sinusoid against default axis in Matlab

So you are just plotting the discrete transform vector against sample position, wish is what Matlab does by default.

  • $\begingroup$ Sorry i haven't enter all the code. I mean i don't understand when we do 'dct' in matlab what is the output plot? magnitude of coefficients against frequencies or something else? I have enter the full code now. $\endgroup$ – 20317 May 19 '13 at 16:01
  • $\begingroup$ Check , my answer again, and comment me if u don't understand $\endgroup$ – Daniel Conde Marin May 19 '13 at 16:11
  • $\begingroup$ I think i understand that i need to add more code to do the job. What i need to alter? $\endgroup$ – 20317 May 19 '13 at 16:32

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.