In this section from Wikipedia about IDFT, three methods are given for expressing the Inverse Discrete Fourier Transform in terms of the direct transform.
Being curious, I implemented the three methods in Octave:
% define TD signal
N = 1024; n = [1:N]-1; f = [4 8];
x0 = sin(2*pi*n'*f/N);
x0 = sum(x0');
% calculate FD spectrum
y0 = fft(x0);
% trick #1
y1 = fliplr(y0);
x1 = fft(y1) / N;
% trick #2
y2 = conj(y0);
x2 = conj(fft(y2)) / N;
% trick #3
y3 = imag(y0) + i*real(y0);
x3 = fft(y3) / N;
x3 = imag(x3) + i*real(x3);
% plot results
plot(n,x0,'m-o', n,x1,'r-*', n,x2,'g-^', n,x3,'bxo');
axis tight
If happens that tricks #2 and #3 work well, while trick #1 fails to generate the correct result.
Am I missing something in the explanation, or is there an error in Wikipedia?
UPDATE: It seems like the magnitude of the y1 result is actually OK, it is just that the angle is doing funny things. Replacing the plot line with:
plot(n,abs(x0),'m-o', n,abs(x1),'r-*', n,abs(x2),'g-^', n,abs(x3),'bxo');
shows the overlap.
x0would then be a row vector, except that you take the sin ofn': n-transposed. Sox0would, I believe, be a column vector. Which means thaty0would be a column vector, and sofliplrwould be operating on a column vector and hence do nothing (at least, this would be the case if Octave works as MATLAB does). Did you check thaty0is a row vector, as expected? – Arkamis Sep 6 '12 at 21:12x0is being transposed in thesum()as well, so I end up with a row vector. Typingwhosshows all vectors have a1in their 1st dimension. – ysap Sep 6 '12 at 21:33