You are on page 1of 5

# Zero Padding Does Not Buy Spectral Resolution - Developer Zone - National Instruments

1/21/12 3:12 AM

## Document Type: Tutorial NI Supported: Yes Publish Date: Sep 6, 2006

Overview This article discusses two common zero padding applications, including speeding up fast Fourier transform (FFT) calculation and the perceived benefit of improved resolution in the results. To complement the text, the article includes several LabVIEW 6.1 examples and tools to explain some of the ideas.

Table of Contents 1. 2. 3. 4. 5. 6. 7. Introduction Zero Padding Now Optional Padded Records Not Always a Good Fit Bin Shift Problems Does Signal = Signal + 0? Distinguishing Resolutions Zero Padding with LabVIEW

http://zone.ni.com/devzone/cda/tut/p/id/4880

Page 1 of 5

Zero Padding Does Not Buy Spectral Resolution - Developer Zone - National Instruments

1/21/12 3:12 AM

http://zone.ni.com/devzone/cda/tut/p/id/4880

Page 2 of 5

Zero Padding Does Not Buy Spectral Resolution - Developer Zone - National Instruments

1/21/12 3:12 AM

When you apply an FFT to a record length that covers an integer number of cycles at the frequency of interest, the bins of the resulting FFT will align with that frequency. Does Signal = Signal + 0? To better understand the effect on the frequency-domain sample spacing when you append zeros to the input, you can plug the changes into the above-mentioned formulas. When you append Nz zeros to an input signal with N samples, the FFT output becomes (N + Nz)/2 +1 samples. Because appending zeros does not change the input sampling rate, the frequency span of the FFT output will remain the same. The new output remains an evenly distributed set of samples spread over 0 to fs / 2. The sample spacing of the new output must decrease to fit more samples over the same frequency range. The slots of the output array now represent frequencies equal to n (fs / (N + Nz)), where n is again the index of the array. The decreased spacing is in the sampled output of the FFT and corresponds to a resolution increase in those samples. It is important to note that this increase does not improve frequency resolution of your analysis of the input signal. Distinguishing Resolutions In this situation, you can distinguish two separate frequency resolutions. The first is the resolution that quantifies the ability to distinguish two closely spaced frequencies from your original input signal. The second is the inter-sample spacing of the array of values that is output from an FFT-based algorithm. The resolution that distinguishes closely spaced frequencies is often the one that is of interest in your analysis because it is relevant to the spacing of frequencies from the original input signal. It is common for this to become confusing because these resolutions are equal if you have not applied any zero padding.

Sufficient frequency resolution allows you to distinguish closely spaced peaks with or without zero padding. The sufficient frequency resolution image provides an example of applying an FFT power spectrum to padded and nonpadded versions of an input signal that contains two main frequency components. The sampling rate and duration of the input signal are such that the frequencydistinguishing resolution is sufficient to distinguish the two components. The FFT Power Spectrum results from the padded and nonpadded
http://zone.ni.com/devzone/cda/tut/p/id/4880 Page 3 of 5

Zero Padding Does Not Buy Spectral Resolution - Developer Zone - National Instruments

1/21/12 3:12 AM

## inputs show clear peaks at each frequency.

Perhaps the most obvious is the built-in subVI from the array-based signal processing palette, "Zero Padder": This VI is a good choice for efficiently increasing an array length to the next higher power-of-two. The benefit is that the array-based FFT algorithms that ship with LabVIEW Full or Pro are more efficient with array lengths that are equal to a power of two. Padding an array with zeros to an arbitrary length requires a custom solution. The VI "zeroPadArrayarbitraryLength.vi" from the library associated with this article does the job for an array, and the code is straightforward. If you are new to LabVIEW, note the use of the initialize array operation in the LabVIEW code for this VI. It is an efficient alternative to building an array on the border of a For loop. If you are working with LabVIEW 6i (or higher) and familiar with the waveform data type (WFD) that was new to that release, you will note that the "Zero Padder" is designed for array-based inputs and outputs. The VIs in the attached library, "subPadWFDarbitrarylength.vi" and "subPadWFDPowerofTwoLength.vi" do the job for the WFD. The LabVIEW code is straighforward:

http://zone.ni.com/devzone/cda/tut/p/id/4880

Page 4 of 5

Zero Padding Does Not Buy Spectral Resolution - Developer Zone - National Instruments

1/21/12 3:12 AM

When you work with the WFD, you want to utilize the high-level tools for spectral analysis including the FFT Power Spectrum and several others. These VIs will not realize their inputs have been zero padded, so you will need to tweak them in certain circumstances. One area that you need to consider involves windowing. Enabling the built-in windowing capabilities for any of these VIs applies the window to the entire block of the input signal. As such, you will not want to apply it to a block that you have padded. To deal with this solution, you can ignore the windowing capabilities of these tools and apply any required windowing externally, as shown in the example VI, "WFDPSDExample.vi." Because zero padding does not affect the input sampling rate, these VIs automatically handle frequency scaling after padding. If you examine "WFDPSDExample.vi", you will see that the LabVIEW high-level FFT Power Spectral Density vi automatically handles the x-axis scaling. (The other high-level FFT-based WFD spectral analysis VIs can also handle this scaling.) I would like to thank several other engineers here at National Instruments for their ideas and technical review of this article: Mike Cerna, Jim Lewis, Jim Nagle, and Yong Rao.

Legal This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).

http://zone.ni.com/devzone/cda/tut/p/id/4880

Page 5 of 5