To download NI software, including the products shown below, visit ni.com/downloads.
Overview
This example shows how to remove all rows that contain all zeros from a 2D Array. This is useful if you have logged lots of data and want to isolate rows that actually contain data.
Description
There are often lulls in data-generating activity during an acquisition. This program sifts through a large collection of data and extracts the meaningful information.
There is one implementation presented here, that uses auto indexing to iterate rows of the 2D array and case structures to control the conditional inclusion of non-zero data.
"Not equal to zero?" function checks if each single row element is zero or not.
"OR Array Elements" combines the results for all row elements and determines if the row needs to be saved to the new output array or not.
The "Index Array" function is used to allocate memory before executing the loop. This is important to prevent new memory allocations in every loop iteration which would happen if using "build array" function or conditional indexed output tunnels.
Requirements
Software
Hardware
Steps to Implement or Execute Code
Additional Information or References
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
Please include a screenshot. Thanks!
Hi
I just found your VI but I could't download due to general errors. Could you please reload the zip file. I really need it,
Thanks
arelone
Recreated and uploaded. Apologies the link was busted. Have fun churning your datas.
Rescaling arrays (using the build or delete functions e.g.) is *extremely* costly (speed and memory-wise) so you should always try to avoid doing it repeatedly, especially on potentially large arrays. So instead of building the result array one element at a time, try reusing the existing one as it is, and then rescale it once afterwards.
I've attached one possible implementation of this here. It's not the optimal solution either, but it keeps the code simple and removes the largest performance issue. (A comparison on a random PC: On a 1000x1000 array where 10% of the rows are all zeroes this VI will run in 9 ms, instead of the original's 1300 ms.)