LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Build Array

Hi,

 

I am kind of rusty, I want to build array in the diagram below.

Note: I know I can use simpler method to achieve this goal, but the specific example is important to my larger scope

 

 

 

22437i960E26C81EFFD526

 

I expect the results:

0

1

2

4

5

10

 

 

hence I do not want the zeros to appear.

0 Kudos
Message 1 of 21
(7,690 Views)

Build Array.vi will work.  Use a shift register initialized with a zero at index 1, and put the Build Array.vi in your False case.

 

EDIT:  BTW, I don't know what your "larger scope" is but using build array in a loop with large arrays is inefficient.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 2 of 21
(7,685 Views)

The easiest way is to use a shift register with an empty array as the initializer.  In the true case, use Build Array, and in the false case wire the array through.

 

What's happening here, is in your false case you are adding a default value (0) to the array, rather than no value, which is what you are assuming happens. (You can tell by the little white box in the tunnel on the case structure). 

--
Tim Elsey
Certified LabVIEW Architect
Message 3 of 21
(7,683 Views)

Maybe this ?

 

 

 

22439i4EDCC7A337844503





Message 4 of 21
(7,673 Views)

Does the arrayALWAYS contain (or start with)

0

1

2

4

5

10

???

 

If so, then you could simply initialize the array by having an array constant with those elements pre-entered.

 

Message 5 of 21
(7,662 Views)

 

22447i33B6DD0BA87A75A8

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 6 of 21
(7,654 Views)

 


@jcarmody wrote:

 

22447i33B6DD0BA87A75A8


Just curious, but is this better, worse or same as using a case structure.  My inclination is it would be better to not build an array every iteration, so the case structure would be a better solution.  Thoughts?

 

--
Tim Elsey
Certified LabVIEW Architect
Message 7 of 21
(7,646 Views)

 


@jcarmody wrote:

 

22447i33B6DD0BA87A75A8


I am in the habit of using a Case structure here.  Using the Select primitive means that the Build Array will operate in every cycle and the wire branching has the potential to mess with inplaceness.

 

Edit: (Great?) minds think alike.

 

Message 8 of 21
(7,645 Views)

I understand, but my solution covers LESS AREA on the Block Diagram and that's the most important thing :O. 

 

<edit - added new snippet>22451iDC5F3B7A0B911DAC

 

I'd have done it differently if this was meant to handle large amounts of data.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 9 of 21
(7,640 Views)

 


@jcarmody wrote:

I understand, but my solution covers LESS AREA on the Block Diagram and that's the most important thing :O. 

 


Plus, those case structures are so darned annoying to work with.... Smiley Tongue

 

Message 10 of 21
(7,608 Views)