FFT Viewer: DFT Magnitude and Phase, Bin by Bin

Enter samples, choose a window and padding, and read the DFT as a plot and as a table of real part, imaginary part, magnitude and phase.

Input (after window and padding)
00.250.50.7510246nx[n]
DFT magnitude
012340246bin k|X[k]|
8-point DFT, X[k] = sum of x[n] e^(−j2πkn/8)
kRe X[k]Im X[k]|X[k]|Phase (°)
04040
11-2.4142.613-67.5
20000
31-0.41421.082-22.5
40000
510.41421.08222.5
60000
712.4142.61367.5

The formulas

X[k]=∑n=0N−1x[n] e−j2πkn/NX[k] = \sum_{n=0}^{N-1} x[n]\, e^{-j 2\pi k n / N}

The N-point DFT. The FFT computes the same numbers in about N log₂ N operations instead of N².

w[n]=0.5−0.5cos⁡2πnN−1w[n] = 0.5 - 0.5\cos\dfrac{2\pi n}{N - 1}

The Hann window: it tapers the ends to zero, which lowers leakage at the cost of a wider main lobe.

Worked example: four ones and four zeros

  1. x = [1, 1, 1, 1, 0, 0, 0, 0], N = 8.
  2. X[0] is the sum of the samples: 4.
  3. For the others, |X[k]| = |sin(πk/2) / sin(πk/8)|: |X[1]| = 1 / 0.3827 = 2.613, |X[2]| = 0, |X[3]| = 1 / 0.9239 = 1.082, |X[4]| = 0.
  4. Bins 5 to 7 mirror bins 3 to 1, since the input is real: X[N − k] is the complex conjugate of X[k].
  • Zero-padding doesn't add information. It samples the same underlying spectrum more finely, so peaks are easier to locate.
  • With N a power of 2 the tool uses a radix-2 FFT; otherwise it computes the DFT directly. The numbers are the same.

Sources