fft based dct and idct

조회 수: 3 (최근 30일)
Ericson
Ericson 2015년 9월 27일
편집: Walter Roberson 2015년 9월 28일
Write two MATLAB functions, called mydct.m and myidct.m, that implement the discrete cosine transform (DCT) and its inverse for a vector of length N. Your code should be short (4 lines or less per function, no loops), ecient (it should make use of the fft command), and match the output of MATLAB's dct and idct commands.
I really have problem in solving this simple question. Could anyone help me?
  댓글 수: 2
John D'Errico
John D'Errico 2015년 9월 27일
I just used google. "dct from fft". surprisingly, I found much there. Ok, maybe not a surprise.
Ericson
Ericson 2015년 9월 28일
편집: Walter Roberson 2015년 9월 28일
Actually I found one, but when I do the inverse dct, I got a large difference. Could you point out my errors?
function w1 = myidct(y)
N=length(y);
x=[y;flipud(y)];
fi=ifft(x);
k=0:N-1;
w1=sqrt(2*N)*real(fi(1:N).*exp(1j.*k'.*pi./(2*N)));
w1(1)=sqrt(1/2)*w1(1);
end

댓글을 달려면 로그인하십시오.

답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by