LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

delete specific element from array

Solved!
Go to solution

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.

0 Kudos
Message 1 of 5
(9,902 Views)

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.

 

- tbob

Inventor of the WORM Global
Message 2 of 5
(9,891 Views)
Solution
Accepted by topic author hiNI

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

Message 3 of 5
(9,870 Views)

I would suggest simpler way to do that

 

 

Message 4 of 5
(7,307 Views)

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


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 5
(7,303 Views)