Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Example Program
NI Supported: Yes
Publish Date: Sep 6, 2006

Zero Padding with LabVIEW

2 ratings | 4.50 out of 5
Print

Downloads

Filename: zerppaddingsw1.zip
Requirements: View

This example code accompanies a Developer Insights article on the same topic titled "Zero Padding Does Not Buy Spectral Resolution".

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.

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.)


Related Links:
Zero Padding Does Not Buy Spectral Resolution

Requirements


Filename: zerppaddingsw1.zip

Software Requirements


Application Software: LabVIEW Full Development System 6.1
Language(s): LabVIEW

 
2 ratings | 4.50 out of 5
Print

Reader Comments | Submit a comment »

 

Legal
This example program (this "program") was developed by a National Instruments ("NI") Applications Engineer. Although technical support of this program may be made available by National Instruments, this program 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 program with each new revision of related products and drivers. THIS EXAMPLE PROGRAM 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/).