Monday, 23 December 2013

FFT calculator

This blog post implements a Fast Fourier Transform (FFT) or an Inverse Fast Fourier Transform (IFFT) on a complex input, dependent on the checkbox setting below.

For discrete time-domain input samples $x[n]$ for $n={0,1,2,..,N-1}$ the FFT (at bin $k$ for $k={0,1,2,..,N-1}$) is defined by equation

$X[k]=\sum_{n=0}^{N-1}x[n]exp(-j2\pi\frac{nk}{N})$

while for discrete frequency-domain input bins $X[k]$ for $k={0,1,2,..,N-1}$ the IFFT (at time index $n$ for $n={0,1,2,..,N-1}$) is defined by equation

$x[n]=\frac{1}{N}\sum_{k=0}^{N-1}X[k]exp(+j2\pi\frac{nk}{N})$

where $N=2^g$ for integer $g$.

Please enter the numbers in the text areas below - one number per line, for each of the Real and Imaginary input textareas (the textareas have already been filled in with some numbers for illustration purposes). There must be no new line after the last number.

Note that if the input is real only, the imaginary input textarea can be left empty (rather than having to fill it with the same number of zeros as there are real inputs, which can be a bit more cumbersome). Conversely, if the input is imaginary only, the real input textarea can be left empty (rather than having to fill it with the same number of zeros as there are imaginary inputs).

Alternatively you can choose to load a CSV file, which must be either a single column of numbers (for a real only input) or two comma-separated columns of numbers - the first line can be a comment line, starting with the character #.

To perform the FFT/IFFT, please press the button labelled "Perform FFT/IFFT" below - the results will populate the textareas below labelled "Real Output" and "Imaginary Output", as well as a textarea at the bottom that will contain the real and imaginary output joined using a comma - this is suitable for copying and pasting the results to a CSV file.

In addition, graphical outputs of the FFT are displayed below. These include a graph of FFT magnitude (using the drop-down menu below, you can select the units of this parameter) and a graph of the phase response (units of either radian or degrees also selectable by a drop-down menu below). When a unit is altered, you would need to perform the FFT again by pressing the calculate button for the changes to take effect.

If you change inputs to a smaller number of samples, please press the calculate button twice for the results to take effect. Alternatively, you can simply reload the page, then fill in the input textareas.

As the FFT operates on inputs that contain an integer power of two number of samples, the input data length will be augmented by zero padding the real and imaginary data samples to satisfy this condition were this not to hold.

You can find an FFT based Power Spectral Density (PSD) Estimator here.



Real Input                         Imaginary Input




                       



Real Output                         Imaginary Output




Real and Imaginary output concatenated on each line:-

FFT Magnitude

Complex (Linear)

FFT bin

Complex (Linear)

FFT bin




FFT Phase Response

Radians

FFT bin

Radians

FFT bin