12-27-2013 10:00 AM
I would like to build an array without including any information that has been set to 0. For example the numbers: 25,13,63,42,0,8,2 would be an array such as this:
25
13
63
42
8
2
If I use the classic build array function, the 0 would be passed because I am taking the numbers from local variables. It would look like this:
25
13
63
42
0
8
2
Any help would be appreciated
Solved! Go to Solution.
12-27-2013 10:26 AM
12-27-2013 10:30 AM
@ncm wrote:
If I use the classic build array function, the 0 would be passed because I am taking the numbers from local variables.
Well, you need to show us your "classic" code, because we have no idea how your code is architected. This way we can easily tell what needs to be done. How are you currently building the array?
Typcally you would keep the array in a shift register, place the "build array" inside a case structure and wire the other case across.
If you have a newer LabVIEW version, you can also use conditional autoindexing tunnels.
Why does the value come from a local variable? What's wrong with using the terminal?
12-27-2013 10:56 AM
Thanks! I am terrible at finding stuff in the forums, this was a great help!! I knew it should be simple =D
12-27-2013 11:08 AM - edited 12-27-2013 11:08 AM
@ncm wrote:
Thanks! I am terrible at finding stuff in the forums, this was a great help!! I knew it should be simple =D
I would recommend against the code shown in the linked thread. That was about removing zeroes from an existing array while you seem to be struggling not to even add them to the array in the first place. 😉
Repetitive use of "insert into array" is very inefficient and can cause huge performance penalties of the arrays are large. There are much better in-place solutions.
12-27-2013 11:51 AM
ncm wrote:
Thanks! I am terrible at finding stuff in the forums, this was a great help!! I knew it should be simple =D
I would recommend against the code shown in the linked thread. That was about removing zeroes from an existing array while you seem to be struggling not to even add them to the array in the first place.
Repetitive use of "insert into array" is very inefficient and can cause huge performance penalties of the arrays are large. There are much better in-place solutions.
___________________________________________________________________________________________________________________________________
I would definitely use any suggestions that I can take, if you have others, I love learning
I am only working with at the most 5 numbers but if my arrays get large, I can tell the code would not be good. I used Search 1D Array and Delete from Array and repeated this 5 times (extremely inefficient) It is just a little quick program I am throwing together but if I want to build on it in the future this would be problematic.
12-27-2013 11:59 AM
12-27-2013 12:07 PM - edited 12-27-2013 12:16 PM
@udka wrote:
Please check this, one way to optimize http://zone.ni.com/reference/en-XX/help/371361J-01/lvconcepts/in_place_element/ (i think this is what altenbach suggesting)
This link has really nothing to do with this discussion. An in-place solution rarely requires the use of the "in place element" structure.
If you have an existing array and need to remove elements matching a certain pattern (e.g. =0), you should could do something like the bottom example linked in my idea here. (while you are at it, vote for the idea! :D)
12-27-2013 12:43 PM