In part 1 of this series, we looked at the formula for the inverse discrete Fourier transform and manually calculated the inverse transform for a four-point dataset. Then, we used Excel’s implementation of the inverse fast Fourier transform (IFFT) to verify our work.
Could we try something more realistic?
Sure. We can take a signal from the time-domain world of oscilloscopes, transform it to the frequency domain world of spectrum analyzers, manipulate it in some fashion, and transform it back to the time domain. Figure 1 shows how to set up the spreadsheet for a dataset with N equals 512 data points—recall that Excel’s fast Fourier transform (FFT) engine requires that N be a power of 2. We put the sample number n in column A, extending from 0 in row 2 to 511 in row 513. We put the time in column B, ranging from 0 to 0.511 s in increments of 0.001 s, which is our sampling interval Δt. In column C, we enter the equation for our sinusoidal input to the FFT, which you can see in the formula bar.
You’ve chosen a frequency of 78.28 Hz. Why?
That frequency lets us fit an integer number of cycles into our 512-point sample space, to avoid spectral leakage, as discussed in part 3 of our earlier series on the Fourier transform. Part 3 also explained how to use windowing functions to minimize spectral leakage for datasets that do not contain an integer number of cycles, but I wanted to keep this example simple.
What’s our next step?
The FFT engine writes the complex FFT result into column D. Column E calculates the magnitude of the complex FFT using the =IMABS() function. Recall also that we need to multiply the magnitude by a scaling factor 2/N. Column F holds the frequency, against which we will plot the FFT magnitude. The frequency begins at zero, and each successive entry increments by an amount Δf:
For details on setting up columns A through F, see part 2 of our earlier series.
What about columns G through K?
Since we have our signal in the frequency domain, we can alter it before transforming it back to the time domain. Thus, column G divides our FFT result by 2. The column D entries are complex numbers, so we can’t simply use =D2/2. Instead, we use the =IMDIV() function. In column H we use =IMABS() again to calculate the magnitude so we can plot it.
Can we now calculate the complex IFFT of the column G values?
Right. As in part 1 of this series, we’ll select Data Analysis from the Data tab. Then select Fourier Analysis, and you’ll see the box shown in Figure 2. Follow the five steps in the figure, noting that the input range is G2 through G513 and the output range is I2 through I513. Make sure to check Inverse in the lower left corner and click OK. The FFT engine writes the complex IFFT into column I. We can then use the =IMREAL() and =IMAGINARY() functions to write the real and imaginary parts into columns J and K, respectively.
Can we plot our results now?
Yes. In Figure 3 at the top, the blue sine wave represents our 78-Hz input with a normalized peak amplitude of 1. The blue trace on the bottom represents the real part of the FFT, with a peak of 1 at 78 Hz, and the red trace on the bottom is one-half the blue trace. When we apply the IFFT, we get the red sine wave on the top, with a peak amplitude of 0.5. The imaginary parts in column K are all zero, so only the real part (column J) is relevant for this example.
It looks like we’ve found a complicated way to divide by two.
Right. But there are many applications — in signal synthesis, telecommunications, and image processing, for example — that require more complex signal manipulation in the frequency domain, followed by an IFFT to construct a time-domain signal. We’ll look at an example next time.
Leave a Reply
You must be logged in to post a comment.