LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

array of array

Hi,

How Can I build and 1-D Array of 1-D Arrays with different dimensions?

For example, I want to place in the first position of my 1-D Array and 1-D Array of dimension 2, in the second position another 1-D Array of dimension 3, and in the third position another 1-D Array of dimension 7. How can I do it?

Thanks,

ToNi.
0 Kudos
Message 1 of 11
(4,800 Views)
An array of 1-D arrays is a 2-D array, so you can't directly do what you're asking with arrays. This array will have 1 row for every 1-D array that you input. The number of columns will be equal to the longest 1-D array. The short rows will be padded with zeros (for numerical arrays).

One way that you could do this, however, is to make your "array of arrays" and then make a separate 1-D array which keeps track of how many elements are in each of the 1-D arrays. When you extract one of the arrays you can then use the Array Subset function with the length coming from your other array to extract only the elements that you need from the 1-D array.
0 Kudos
Message 2 of 11
(4,793 Views)
Ok, but... is it not possible to do it without padding zeros to short columns?

Is there any way to remove the padding zeros from a 1-D Array automatically? because if not, I must know the length of each column in order to extract the items I am interested in.

Thanks,

ToNi.
0 Kudos
Message 3 of 11
(4,788 Views)
Easiest would be to place an 1D array in a cluster, then place it inside another 1D array. Now you have an array of clusters, each containing a 1D array. (see image).

Still it is probably more efficient to use a 2D array with e.g. the first row containing the length of each column. so you can extract the correct subset later. Alternatively, if your array is orange, you could pad with a special value, (e.g. NaN, -Inf, Inf) if these don't normally occur in your data.
Message 4 of 11
(4,783 Views)
As altenbach said, bundle each 1-D array, then make an array of those bundles.
Each array can then have as many elements as it needs without any waste.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 5 of 11
(4,779 Views)
Ok, I am doing it,

Thanks to everybody,

ToNi.
0 Kudos
Message 6 of 11
(4,768 Views)
Hi again,

I have done a little example in LV 7 Express. I have an 1-D Array of 1-D Array with different dimensions.

In the example I attach I have a 1-D Array(1) of 1-D Array. My 1-D Array(1) is dimension 3 and in each position I have a 1-D Array. The first position (firts column) contains an 1-D Array with dimension 1, the second position (second column) another 1-D Array with dimension 2 and finally, the third position (third column) contains an 1-D Array with dimension 3. The short 1-D Arrays are padded with zeros. Now, I want to extract the first column (first 1-D Array with dimension 1 of the first position of my 1-D Array(1) ) without the padded zeros and I use an Array subset but It doesn't work, It returns to me the padded zeros and I don't want the padded zeros. I pass as a parameter the length I want to read for the first column to the subset but I don't know because it returns me padded zeros.

Why?

Thanks,

ToNi.
0 Kudos
Message 7 of 11
(4,766 Views)
ToNi,

You need to add the actual length as first element, then, after getting the row, take the 1D array subset of [start=1, lenght=A(0)]. See attached.

Message Edited by altenbach on 04-02-2005 11:38 AM

0 Kudos
Message 8 of 11
(4,754 Views)
And here is a variation using clusters. 🙂
0 Kudos
Message 9 of 11
(4,747 Views)
Hi,

John Rich and altenbach have given you a good solutions (it´s better using cluster to do a array of arrays).

You aren´t afraid if your final array is padding with zeros. These zeros are dimmed and these aren´t adding to your final array.

Regards

Diego M.
0 Kudos
Message 10 of 11
(4,696 Views)