From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to build an array inside a loop

Solved!
Go to solution

If you can, you should try to insert rows instead of columns and arrange the data in memory accordingly (you can always transpose for display later). Inserting columns is much more expensive because the inserted elements are not in memory order and lots of things need to be shuffled around.

0 Kudos
Message 11 of 14
(974 Views)

griff32 wrote:

Try looking at this VI I wrote, It takes a 1D array and puts it into a 2D array based on a threshold. I think it is a pretty good example on how insert an array works. I hope it helps


 

There are quite a few Rube Goldberg constructs, such as the following:

 

 

 

I think we need a much clearer picture of what the task really is. I am sure there is a solution that takes only 10% of your code.

 

 

0 Kudos
Message 12 of 14
(968 Views)

I knew I would get a reply like this if I posted that code. It was only an example not the solution.

 

Very predictable around here.

0 Kudos
Message 13 of 14
(949 Views)

@andrew_ryan wrote:

 

In this example, i have a single column with the values [1 2 3 4 6 7 8 9 11 12 13 14 16 17 18 19 21 22 23 24]

while I would like to have an array of 5 columns:

1   6   11   16   21

2   7   12   17   22

3   8   13   18   23

4   9   14    19   24

 

Note than this is just an example. More generally, the array can contain columns of different lengths.


Can you give an example of the "more general" situation where the lengths differ? Do they differ between columns in the same run or are they constant for a given run?

 

Your above problem can be solved "loop free", of course. So obviously there is more to it in general.

 

 

0 Kudos
Message 14 of 14
(945 Views)