LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dealing With Non Uniform Array Sizes

Would it be possible to store data such as

1 2 3 4 5 6

0 2 4

3 1 4 1 5 9 2 6 5 3 5 8 9

 

Where each row is not nessicarly the same length. I need to later call a specific row by row number and plot the 1D array. I have figured out arrays wont deal with the non uniform length and will instead fill in the extra elements so they all match in length. Is there any way around this?

 

Thanks

0 Kudos
Message 1 of 13
(3,803 Views)

Place the arrays in a cluster. Then make an array of the clusters.  The array of clusters has only the cluster containing the array of numerics. The individual arrays of numerics can have different lengths.

 

Lynn

0 Kudos
Message 2 of 13
(3,768 Views)

you can take a 2D array and during plotting of data you can index any row and then delete the empty elements from the array before plotting.

0 Kudos
Message 3 of 13
(3,710 Views)
The problem with that idea is that the elements are not empty. They will be zeroes and that seems to be a valid entry.
0 Kudos
Message 4 of 13
(3,700 Views)

The issue is that I'm making the arrays in a loop and I cant find a way to insert an array into a cluster instead of building a cluster from multiple predefined arrays.. If that makes sense.

 

I need something much like the insert into array function except for clusters. Maybe I'm missing a way to do that.

0 Kudos
Message 5 of 13
(3,658 Views)

You can simply connect the arrays to a Bundle node.

 

Look at this VI which demonstrates the concept.

 

Lynn

0 Kudos
Message 6 of 13
(3,645 Views)

Let's assume you have two stacked FOR loops, generating a scalar in the center. Auto indexing across both loop boundaries would give you a 2D array. If the number of iterations in the inner loop is variable and you want a ragged array, insert a"bundle" of height=1 between the two output tunnels.

0 Kudos
Message 7 of 13
(3,642 Views)

For Posterity, here's one of Darren's nuggets on the subject, the thread has a decent conversation on this handling jagged arrays:

 

Darren's Occasional Nugget 05/09/2012

http://forums.ni.com/t5/LabVIEW/Darren-s-Occasional-Nugget-05-09-2012/td-p/1984521

 

Note that the suggestion there is more or less what Lynn suggested. 

 

Regards,

Tom L.
0 Kudos
Message 8 of 13
(3,630 Views)

I had to make a few adjsutments so it would work with shift registers and I had to make sure to connect the terminals into the insert array function in the right order so the connections would be valid but now it works. Thank you. I included the changes.

0 Kudos
Message 9 of 13
(3,621 Views)

It is generally better to use Repalce Array Subset or autoindexing to build an array. Insert into Array may cause memory allocation problems. Here are two mnodifications to your VI which show both methods. If you need to see the results as you go, the Replace Array Subset is best. If you do not need the data until the for loop completes, autoindexing is the preferred choice.

 

Note that you may need to initialize your shift register. Run the VI multiple times and watch the results.

 

Lynn

0 Kudos
Message 10 of 13
(3,604 Views)