09-19-2011 05:30 PM
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
09-19-2011 05:40 PM
That's how I do it. It's fast and very legible.
09-20-2011 11:04 AM
thanks!
09-20-2011 12:06 PM
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. 😉