This is the fifth article of “The OpenG VIs that I couldn’t live without“, a series of articles showing some of my favorite OpenG VIs. In this article, I’m going to show a very useful VI, Filter 1D Array, that is used to filter items out of a 1D array.
Let’s take a look at a couple simple examples of this VI in action.
In this example (shown below), we are filtering out all values of +Inf and -Inf from a 1D array of DBL floating point numbers. We simply specify an array of items that we wish to filter out of the input array and Filter 1D Array does the rest.
In our next example (shown below) we will notice that Filter 1D Array is Polymorphic. First, we notice that this example is filtering items from an array of strings (or previous example used a DBL floating point array) and, second, we notice that we are wiring a scalar value (empty string) into the “items to filter” (our previous example used an array of items to filter). You can see in this example that all of the empty string elements were removed from the input array. Very cool!
One other thing that you should also know (that we did not highlight in the above examples), is that Filter 1D Array outputs an array of indices (pointers) of the items that were removed. This allows you to do operations on associative arrays (see wikipedia definition of associative array) — an advanced programming technique.
If you want to give this VI a try, you can obtain it using VI Package Manager (VIPM). Simply select the OpenG Array Library (the oglib_array package from within VIPM), you will find the OpenG Array Tools palette in the Functions palette under the OpenG submenu. (See here for a quick guide on how to install OpenG on VIPM.)