I'm trying to implement DFT/IDFT and FFT/IFFT in Matlab and C.
I got wrong values while I implement IDFT/IFFT. So I'm trying to find a mistake.
Just for DFT, I used this algorithm to implement it in Matlab (from matlab's fft doc) But I really don't know why there is very small errors when I run this code. and even my Radix-2 FFT have same problems. Is there anything I'm missing or can I ignore this values? (mean of 256 values : -1.6881e-25)
Thank you for reading this.
for i=1:256
x(i) = sin(2*pi*i*80) + sin(2*pi*i*46);
end
X = zeros(256,1);
for k=1:256
for n=1:256
X(k)=X(k) + x(n)*exp((-j*2*pi*(n-1)*(k-1))/256);
end
end
built_in = fft(x);
error = abs(X) - abs(built_in)';
plot(abs(X)); hold on
plot(abs(built_in));
plot(error);
legend('My code', 'Matlab','error');
with result: