Real time FFT – Wouldn’t zero-padding a signal at the end distorts the output?

Yes, it can.

But whether that’s the most important thing to worry about depends on how you got the signal in the first place, and where you’re doing the processing.

If you’re actually sampling a periodic signal, and your sampling is exactly synchronous to that signal, then zero padding is bad. As a concrete example, say you’ve arranged to sample a power line at 1200Hz for 100ms, from a clock that’s locked to the power line phase. You have an integer number of cycles, and to the degree that the input is actually periodic, the tail matches the head perfectly.

You almost never do that.

Usually, if you’re doing an FFT on collected data, you’re either using it for fast convolution or you’re analyzing some arbitrary signal taken from the real world.

If you’re doing fast convolution, you zero-pad so the output of the fast convolution has died off before it gets to the end of the output vector.

Typically when you’re analyzing data with the FFT, you sample over what is, from the world’s point of view, a random interval of time. In general, spectral components of the actual signal don’t have periods that match the length of your sample.

This distorts your spectrum!

Basically, if this is the reason you’re using the FFT, then when you take a continuous-time signal and sample it you’re making an approximation (you’re throwing away everything between your samples), then when you select a finite-length chunk of that sampled signal you’re making another approximation (you’re throwing away everything past the ends).

By the time you take that twice-approximated signal and zero-pad it, the spectrum is already pretty battered — zero padding it isn’t going to hurt. At this point, zero-padding, detrending, and windowing your signal before FFT may very well help to get the most accurate representation of the real signal’s spectrum.

Read more here: Source link