3
$\begingroup$

I have a complex signal with a frequency between 0 and 16 (16 not included). I have made four plots (in python) to show four examples. For each example I provide the signal, its FFT in both real, imag and absolute form and I show the real vs imag plot in the bottom for each example.

I was wondering whether someone could explain to me one or more of the following three questions:

  1. why the signal with frequency 15 has only one period, rather than 15 periods as I would expect? Maybe with relation to the bottom plot.

  2. for example in the plots of frequency of 1 Hz, why do the real and imaginary components in the FFT cancel out at 15.0 but resonate at 1.0?

  3. The Frequency of 1 Hz and frequency of 15 Hz have about the same real vs imag plot but are reversed (looking at the sampling point colours). How is that a relation between 0 and 15 Hz as the peak for the FFT?

I have never had big brain when it comes to signal processing so I would like to learn what is going on here and how these three plots per frequency relate.

Frequency of 0 Hz:

Frequency 0


Frequency of 1 Hz:

Frequency 1


Frequency of 7 Hz:

Frequency 7


Frequency of 15 Hz:

Frequency 15

$\endgroup$

1 Answer 1

6
$\begingroup$

Each bin in the DFT result does not represent a sinusoid but is a spinning phasor in the time domain as $x[n] = c_k e^{j\omega_k n}$. For those less familiar, the form $Ke^{j\phi}$ with real $K, \phi$ is just another way of writing $K\angle{\phi}$, so $e^{j\omega n}$ has a magnitude of 1 and a phase that is linearly increasing with time. The coefficient $c_k$ is a complex magnitude and phase representing the magnitude for that particular spinning phasor with frequency $\omega_k$ and starting phase at time sample $n=0$. The DFT is showing us the correlation of an arbitrary time domain function to each of the possible spinning phasors as represented by each bin in the DFT. The first bin is DC and does not spin, the second bin spins once in the total time duration, the third bin spins twice, the fourth three times... The "spinning" is a step in phase on each step forward in time of a constant radius vector on the complex plane (as we see in the OP's plots). This is consistent with frequency as the time derivative of phase: a change of phase with a change in time.

For larger frequencies (higher bin counts) the phase step is larger. For steps between $\pi < \phi < 2\pi$, such as $\pi + x$, the phase step is equivalently $2\pi-(\pi+x)$ such that the rotation will visually appear to be (and is equivalently for all cases) spinning in the other direction.

why the signal with frequency 15 has only one period, rather than 15 periods as I would expect? Maybe with relation to the bottom plot.

for example in the plots of frequency of 1 Hz, why do the real and imaginary components in the FFT cancel out at 15.0 but resonate at 1.0?

The Frequency of 1 Hz and frequency of 15 Hz have about the same real vs imag plot but are reversed (looking at the sampling point colours). How is that a relation between 0 and 15 Hz as the peak for the FFT?

This is when $k=15$ and $N=16$ which means on every sample in time as we move forward from $n=0$ to $n=15$ the phase will step $15/16 (2\pi)$ radians, which is a counter clock-wise rotation on the complex plane. This is identical to a clockwise rotation of $1/16 (2\pi)$

Phase step

Further when the phasor rotates counter-clockwise in time, we refer to that as a "positive" frequency, and when the phasor rotates clockwise we refer to that as a negative frequency. What we are seeing here demonstrated is that for sampled systems and the DFT, the result is periodic in the frequency domain: The bins in the upper half of the DFT equally represent negative frequencies.

Here's an animated demo I have showing all this for the DFT result of [0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1] and showing how both phasors sum in the time domain (the center plot) to recreate a real cosine (which is also plotted as magnitude and phase on the left).

vector spin

Below is a plot with more samples in the time domain to show how the continuous time inverse Fourier Transform would appear if we had a single tone at frequency 1 and another at frequency 15. Note how the result still passes through the large red dots, which are the inverse DFT result for the equivalent sampled system sampled at frequency 16 as previously depicted (so when the waveform is sampled at just the location of the big red dots, as it would be with a sampling rate of 16 the result is the inverse DFT. This plot visually shows us two phasors, both spinning counter-clockwise consistent with positive frequencies, one spinning at rate 1 and the other spinning at rate 15. This demonstration is consistent with the typical presentation of DFT bins starting at bin 0 and extending to represent just the positive frequencies.

inverse DTFT

To demonstrate the periodicity in the frequency domain, and specifically how the second half of the DFT array equally represents negative frequencies (we saw in the OP's example how $k=15$ is also $k=-1$. To change from representing the frequency as all positive frequencies to all negative frequencies, we move the second half of the resulting DFT to the first half and change the axis to extend over negative and positive frequencies. This is done conveniently for us with the fftshift command in Matlab, Octave and Python's scipy.signal. For the example shown in the animation the DFT was [0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1], and k was [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]. After using `fftshift', the frequency index that is positive and negative frequencies would be k = [-8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2,3,4,5,6,7] and the shifted DFT bin values would be [0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0]. This is plotted on the right for the animation below showing the same result after the fftshift. Note that these last two animations are a continuous time interpretation of the inverse DFT operation, and the result in the end only exists at the 16 large red samples shown in the time domain. For that all the plots will have the same result.

positive and negative frequencies

Like what you see? These animations and other cool demonstrations like this are part of my DSP courses where I try to bring intuition together with the math involved for a deeper and more creative understanding of signal processing concepts. You can find the latest course listings at https://dsprelated.com/courses and https://ieeeboston.org/courses/ Course registration is open now for courses starting at the end of Feb 2024, with an early sign-up discount until Feb 15!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.