LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

build array

Solved!
Go to solution

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

-ncm
0 Kudos
Message 1 of 9
(3,006 Views)
Solution
Accepted by topic author ncm
Use simple case structure and comparison to check and then build array.
Check this http://208.74.204.114/t5/LabVIEW/delete-0-from-array/td-p/2052658
-You need to upload what you have done also to give better idea.
Thanks
uday
Message 2 of 9
(2,995 Views)

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

0 Kudos
Message 3 of 9
(2,992 Views)

Thanks!  I am terrible at finding stuff in the forums, this was a great help!!  I knew it should be simple =D

-ncm
0 Kudos
Message 4 of 9
(2,976 Views)

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

0 Kudos
Message 5 of 9
(2,964 Views)

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. :smileywink:

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 Smiley Happy

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. 

-ncm
0 Kudos
Message 6 of 9
(2,943 Views)
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)
Thanks
uday
0 Kudos
Message 7 of 9
(2,938 Views)

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

0 Kudos
Message 8 of 9
(2,931 Views)
Sorry, if it was misleading this discussion.
-I was thinking of multiple copies of large arrays as problem there and posted that in-place element usage. Sorry for that.
Thanks
uday
0 Kudos
Message 9 of 9
(2,915 Views)