Each bin in the DFT output corresponds to a particular frequency. We can determine the frequency of a given bin using the following equation,
The frequency of the k^{th} bin is given by,
k × (sampling_rate / N)
_{Where N is the number of samples in the input signal}
Recall that the sampling rate used in our last few examples is 8Hz.
This means that the frequencies of the output bins for our examples are 0Hz, 1Hz, 2Hz, 3Hz, 4Hz, 5Hz, 6Hz, and 7Hz. Play around with the following visualization to see how the bin frequencies are laid out as the number of samples in the input (N) changes.
Figure 1. Frequency Layout of DFT Bins _{ Sampling Rate is assumed to be 8Hz }
Notice that the bins are always evenly distributed across the frequency spectrum from 0Hz up to the sampling rate. Notice too, that the bins are always harmonically related. In other words, all bin frequencies are multiples of the second bin frequency (the bin right after the DC bin). You can think of this frequency as the fundamental frequency of the DFT, and calculate it as (sampling rate / N) hertz.
INCREASING THE FREQUENCY RESOLUTION
COLLECTING MORE SAMPLES
As the number of input samples increases, we can see that the resolution of the DFT output will also increase. If you need a higher resolution in the DFT output, you simply provide a longer input signal to the DFT.
We often choose a DFT resolution which is high enough to allow us to distinguish between sinusoidal components which are close to one another in frequency.
For example, let’s suppose that we’re trying to analyze a signal which is composed of two sinusoids. One of the sinusoids has a frequency of 5 Hz and the other has a frequency of 6 Hz. Figure 2 shows the composition of this compound signal. The 5 Hz phasor is shown in blue, and the 6 Hz phasor is shown in orange.
Figure 2. A Compound Waveform Composed of Two Sinusoids At 5 Hz and 6 Hz
Since this signal is composed of two sinusoids, we would expect to see two peaks in the DFT output. One of these peaks should appear at 5 Hz, and one at 6 Hz. Since both of the circles have the same size (magnitude), we would also expect the two peaks to have the same height.
In order to properly identify these two individual sinusoids, we must increase the frequency resolution of the DFT output. This is accomplished by increasing the number of input samples which are fed to the DFT. Figure 3 allows you to vary the length of the input signal in order to see the effect on the DFT output. The two “expected” peaks are shown in red. Drag the slider at the bottom of Figure 3 to increase or decrease the length of the input signal.
Figure 3. Increasing DFT Resolution by Collecting More Input Samples
There’s a very fundamental trade-off being demonstrated in Figure 3. In order to achieve high-resolution in the frequency domain, we must collect many samples in the time domain. The resolution of our DFT output is directly proportional to the length of the input signal we feed it.
This idea has big implications if we’re interested in performing high-resolution frequency analysis in real-time. The more input samples we need, the longer we have to wait for them. The longer we wait, the more latency we introduce into our analysis process. High resolution in the frequency domain implies a decrease in our time-domain resolution.