LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

conditionally append to array

hey guys,

 

i would like to append a data to an array conditionally, meaning if it falls in a certain condition, it will append the data into an array and otherwise not append to an array. i need this to avoid redundancy in my data.

 

i was thinking of having a case structure with a "build array" in the true statement and nothing otherwise. was wondering if there is a better way to solve this. sorry, i don't have labview in this computer. any help would be appreciated. thanks in advance.

 

-sam

0 Kudos
Message 1 of 4
(2,683 Views)

That's how I do it.  It's fast and very legible.

0 Kudos
Message 2 of 4
(2,681 Views)

thanks!

0 Kudos
Message 3 of 4
(2,658 Views)

Well, you also need to wire the array across in the false case (that's not nothing ;))

 

(This is suitable for occasional appending. If this is in a tight loop and you eventually append millions of elements, it is often better to work on fixed sized arrays (e.g. containing initially NaN) and replace elements as needed. This is much more efficient because it avoids constant memory allocations. Also make sure to keep the array in a shift register or feedback node. (Don't shuffle it around using local variables for example).)

 

If you have any doubts, show us your VI. 😉

0 Kudos
Message 4 of 4
(2,646 Views)