I'm trying to understand how DFT works exactly. However, when experimenting around, I compared both Matlab generated FFT result with a dummy approach result and I get similar result.
However, the Imaginary part of both results are negated. The code below is my implementation. The implementation of dummy approach is based on http://en.wikipedia.org/wiki/Discrete_Fourier_transform#Definition
$$ X_k = \sum_{n=0}^{N-1}x_n . e^{-i2\pi kn/N}\,. $$
Fs = 500; % Sampling frequency
T = 1/Fs; % Sample time
N = 1000; % Length of signal
t = (0:N-1)*T; % Time vector
x = cos(2*pi*100*t)+randn(size(t));
% Calculate by using Matlab build-in FFT
fdft = fft(x);
% A dummy way to calculate DFT
n = 0:N-1;
k = 0:N-1;
kn = bsxfun(@times, n', k);
dummydft = x * exp(-i * 2 * pi * kn / N )';
Is there anything I miss? Thank you.