07-07-2010 11:05 AM
Hello,
I would like to remove all "0" values from array.
In the following array:
-60
-50
0
-60
0
0
-55
the resutling array to be returned should be
-60
-50
-60
-55
Any help will be greatly appreciated.
Thanks,
hiNi.
Solved! Go to Solution.
07-07-2010 11:28 AM - edited 07-07-2010 11:29 AM
Wire the array to a For Loop with indexing enabled. Inside the loop, wire the array element to an equal function. Wire a constant 0 to the equal. Send the output of the equal to the question mark of a case structure. Create a shift register and initialize it with an empty array of the same data type as your input array. In the true case, wire the shift register straight through. In the false case, use Build Array to add the array element to the shift register array. The output of the shift register will only contain non-zero items.
07-07-2010 12:13 PM
Did you try a search? This question has come up dozens of times.
If the array is small then Build Array in a loop like described is fine. However, for large arrays this is a BAD way to do it. Instead, you need to an alternate approach
08-31-2018 06:59 AM
I would suggest simpler way to do that
08-31-2018 07:23 AM - edited 08-31-2018 07:23 AM
@guyfawkes wrote:
I would suggest simpler way to do that
Yes, using the conditional tunnels (which came out 2 years after this thread) is definitely the way to go.