LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FFT and zero-padding

Hello,
I'm currentlydevelopping an application which calculates FFT from points stored in big files. I'm reading these points and store them in constant size arrays. When I reach the end of the file, the last array may be shorter than the other ones. That's why I'm adding zeros at the end so it has the same size than the others => zero-padding.

But there's something I don't understand : adding a lot of zeros at the end of the array reduces the amplitude of FFT result !!! Which is, I think, incredible because zeros don't add any energy in the signal and don't add any frequencies in the spectrum....

So why zero-padding is reducing the amplitude of the FFT result ?
CLA, CTA, LV Champion
View Cyril Gambini's profile on LinkedIn
This post is made under CC BY 4.0 DEED licensing
0 Kudos
Message 1 of 12
(10,291 Views)

Zero padding is typically done in the frequency domain, in which case you simply increase the resolution in the time domain without adding distortions (basically an iterpolation).

You seem to pad the time domain signal. This is very difficult to justify because it dramatically distorts the signal. Why do you think you need to have the same sizes?

0 Kudos
Message 2 of 12
(10,280 Views)
Dear Altenbach,
As I said in my first message, I read data points from files. These files are quite bid and reag them all at once would completly fill my RAM. So I'm reading a fix number of points, process a partial FFT, then read the following points, process a partial FFT, etc... Then I average the partial FFTs to retrieve the complete FFT.

Zero-padding has to be done on the time domain signal as it's said in LabVIEW help : "FFT Fundamentals". Adding zeros to a time domain signal doesn't had any distorsion because you don't increase the energy contained in your time domain signal.
Moreover, zero-padding only lower the amplitude of my FFT "peaks"... which is, for me, not comprehensible...
CLA, CTA, LV Champion
View Cyril Gambini's profile on LinkedIn
This post is made under CC BY 4.0 DEED licensing
0 Kudos
Message 3 of 12
(10,257 Views)
Hi all!
   usually, zero padding is done in time domain, to increase the number of samples over which FFT is calculated in order to have an increased spectral resolution (more points in frequency domain).  But these points, of course, don't add information, since they're quite fake.  They're useful to have a clearer curve, rather than an FT in which important frequency components are in the middle of frequency-domain samples.

   Apart from this, it is obvious that zero padding decrease the energy of FFT!!!! Think it this way: if you have a wave, sampled for  second, you'll have an energy (say X), now, if you add zeros in time domain, to the same wave, to reach 2 seconds, for half the time you'll have an energy X, for the resting half you'll have an energy of ZERO! If you calculate the FFT of the zero-padded wave, you'll have a mean energy, because FFT is averaged over the total sampling time, in our example, 2 seconds.

   I hope this is quite clear, I've tried to present it in a simple way...

graziano
Message 4 of 12
(10,255 Views)
Hi Graziano !
Thank you for answer. Your explication is very clear and helps me a lot. To find the good amplitude, can I multiply the FFT result by the inverse of the percentage of zeros in the array ?
CLA, CTA, LV Champion
View Cyril Gambini's profile on LinkedIn
This post is made under CC BY 4.0 DEED licensing
Message 5 of 12
(10,251 Views)
Hi!
   Actually, it's been a long time I don't work with DSP Smiley Sad
 
   I cannot give a correct answer to this, I don't remember if there was some square/root or anything else. I would say that there's a linear relationship between FFT and zero-padding, but I'm not sure of that!

graziano

PS.: thanx for the stars!


PPS.: I've found no references on the net, while I've found this arcticle, describing many FFT features.


Message Edited by Graziano on 04-14-2008 03:16 AM
0 Kudos
Message 6 of 12
(10,246 Views)
Simple VI, to show zero-padding - FFT behavior.  But it's not enough to say about the linear relationship!

graziano
Message 7 of 12
(10,240 Views)
Thanks for the answers, files and link ! I'll try to manage it and make it work !
CLA, CTA, LV Champion
View Cyril Gambini's profile on LinkedIn
This post is made under CC BY 4.0 DEED licensing
0 Kudos
Message 8 of 12
(10,234 Views)

The problem is that you have a truncated wave and thus zero padding adds a sharp boundary with many new frequencies. Look at the FFT before and after padding in the above example.

Zero padding in the time domain is typically done in decaying wave signals (such as encoutered in NMR FIDs), where the signal has nearly disappeared at the end due to T2 effects. In these cases, zero padding is much more appropriate. That's how I use it.

For example, the following image shows a simulated DEER signal. Here zero padding does not cause much distortion, because the signal has basically decayed to zero. However, zero padding is needed to get a reasonable resolution in the fourier transform. For example, a plain transform without padding will not be able to describe a frequency that contains 1.5 periods in the original signal, while after padding to twice the size, it would be an integer number of periods and thus correspond to a value in the transform.

 

Since you are chopping up your (very long) original signal, you are probably not interested in the very low frequency signals anyway and I doubt that zero padding is really waht you are looking for. If you zero pad, you might want to add a windowing function to soften the sharp boundary and the patch location. Can you show us some typical data? Maybe it would be more reasonable to just toss the extra tail. Maybe you could also include an overlapping piece and do the last transform with a subset of equal size ending at the end of the data and including some of the data from the previous piece?

If the frequencies really change over time and that last piece is very important, you might need to do something more fancy anyway, e.g. a sliding widow. Have a look at the JTFA toolkit (http://zone.ni.com/devzone/cda/tut/p/id/3548).



Message Edited by altenbach on 04-14-2008 08:11 AM
Download All
Message 9 of 12
(10,193 Views)
Hi all!
   I agree with Altenbach, of course you have to be careful in using zero-padding.  I usually introduce zero-padding when I want to clearly see the amplitude of the main frequency in the spectrum.  If you have to keep a correct spectrum of other components, you'll have to tune zero-padding technique, mainly with windowing.

graziano
0 Kudos
Message 10 of 12
(10,164 Views)