Understanding the output of FFT
So you run your FFT, eagerly anticipating the beautiful list of Frequencies and magnitudes that you’re about to find in your signal. However, all you get in your output of FFT is a weird list containing numbers like this:
2.35106847633105 + 1.35738965249929i
-6.30804542159001 - 3.64195208976973i
11.4044556537143 + 6.58436517126335i
-13.8931356941186 - 8.02120600654118i
11.4044556598216 + 6.58436516773739i
-6.30804540934614 - 3.64195209683888i
2.35106849477125 + 1.35738964185293i
-0.59043852564943 - 0.340890233552048i
“What is this nonsense?” you ask yourself. Wasn’t I meant to get a list of the Frequencies, Magnitudes, and Phases for each Sine wave in my signal??
The answer is, well you have…. sort of, but you’re going to have to do a few more calculations to turn the above into the form you wanted.
What you’ve got is the raw output. Remember the Fast Fourier Transform (FFT) is just a more efficient version of the Discrete Fourier Transform (DFT), which in itself is just a modified Fourier Series, and the Fourier series gives its answers in complex numbers. I’ve covered how to perform mathematical operations with complex numbers before in Lecture 5; however, in this post, we will see how to use the output of FFT to find all the frequencies with their magnitudes and phases which exist in our signal.
Understanding the output of FFT : From Signal to Spectrum
For understanding the output of FFT, Let’s start with a signal:
I’m going to perform a 1024-point FFT on this signal. Remember that number; it is going to be very important later on. The resulting output of FFT will therefore contain a list of 1024 complex numbers.
Below is the list of results of the output of FFT:
Now how do I convert this list into something useful?
Magnitude
To get the magnitude information in output of FFT out of the complex number for each point, we use Pythagoras.
$$ Magnitude= \sqrt{Real^2 + Imaginary^2} $$
Phase
To get the phase information in output of FFT out of the complex number for each point, we use the inverse tangent.
$$ Phase = tan^{-1}\left ( \frac{Imaginary}{Real} \right ) $$
What about the Frequency?
Remember the number I said to remember above? I said we were going to use a 1024-point FFT. This means that the size of our FFT, or in other words, the number of times we sampled our signal is 1024. Let’s call this value N such that:
$$N = 1024$$
Now we need to calculate the sample rate which I’m going to call R. The signal above lasts for 10s in total. If we sampled it 1024 times over that period then our sample rate is:
$$R = \frac{1024}{10} = 102.4 \, Hz$$
Next, we number each sample. Let’s call this number k where:
$$k=0, 1, 2, …, 1023$$
To work out the frequency \( f \) for each item in our list of 1024 FFT results we use the following formula:
$$ f = \frac{k}{N} \times R $$
In the following list of results of output of FFT, I have calculated the Magnitude, Phase and Frequency for each sample according to the formulae above.
I can now plot Magnitude and Phase Graphs for this signal.
Understanding the output of FFT : The Nyquist Rate and Aliasing
You’ll notice in the Magnitude graph in the output of FFT, that most of the frequencies in the signal have zero magnitude. Only a small band of frequencies exist around 5Hz. This is not very surprising as you can clearly see a 5Hz sine wave within the signal. What is strange, however, is that there is another peak in the Magnitude graph around 97.4Hz but there clearly is no such frequency present in the signal.
I’ll deal with the full mathematical reason for this in a later article, but for now, let’s just call it a quirk of the maths.
What is interesting to notice, however, is that the second peak at 97.4Hz is a mirror image of the first. The mirror itself sits at 51.2 Hz, exactly half of the sampling rate R=102.4 Hz. This half-way point is called the Nyquist Rate. The Nyquist rate is the maximum frequency our signal can contain if it is to be faithfully reproduced after sampling. Any frequency higher than the Nyquist rate will be aliased or reflected back into the frequency range below the Nyquist rate.
To hear what this sounds like, listen to the following example:
This is very important when trying to work out at what frequency it is best to sample your signal. Your sample rate must always be at least twice the maximum frequency present in your signal. This is why CD-quality audio is sampled at 44.1 kHz. The maximum frequency the human ear can hear is 20 kHz. If you are listening to a recording of an orchestra, the sound of some of the instruments, cymbals, for example, may well contain such high frequencies. Therefore, CD-quality audio uses a sample rate of 44.1 kHz, a little above the minimum requirement of 40 kHz.

