Comparison between numerical precision in FFT and manual FT: both error plots show very different behavior
4 views (last 30 days)
Show older comments
Hi, I was hoping someone could help me understand the effects of the numerical precision in Matlab's FFT. I setup a very simple code that perform the FFT and IFFT and compare my results to an FFT follwoed by a "manual" IFFT, I see a very strange increasing behavioir in the error and was wondering what this was due to. The fact that it increases with the sample number leads me to believe it's related to the index but I am not sure how I can mitigate this problem.
CODE:
N = 2^13;
x = rand(N,1);
xk = fft(x,N);
y = ifft(xk,N);
yr = zeros(N,1);
for k=1:N
yr = yr + xk(k)*exp(1i*2*pi*[0:N-1].'*(k-1)/N);
end
figure;
plot(abs(yr/N-x))
title 'hand ifft'
figure;
plot(abs(x-y))
title 'ifft'
Could it be the constants values? how does fftw actually handle these numbers.
Thanks for the help.
Alex
4 Comments
Answers (0)
See Also
Categories
Find more on Fourier Analysis and Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!