LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

create an array of 2D array

Hi All,

I see that there are two schools of thought. One is to go with 3D, 4D arrays. The other to Use Cluster and Keep your Arrays Separate.

With 3d Arrays, the problem is it will have a size such that it can acomodate the largest 2d Array. So other smaller 2d Arrays will be tagged with Zeroes. One Way to get around this is to initialize your 3d Array with NAN. The problem is you must again know before hand the size of this 3d array. I am attaching an example how 3d Array initialized with NaN can populate 2d Arrays.

I do not Like Cluster Structure as it gets Cumbersome and Hogs a Lot of Memory. Not to Mention the various bundling and Unbudling Operations. Also if you want to save this data for use in spread sheet you have to "twist and shout". May
be a wrong metaphor?

What I like to do is no matter what Save all my data in 2d array. So I can represent a 3d,4d array in 2d Array form just by using First columns to show the index of various 2d Arrays. (1 column as index for 3D, 2 Columns for 4D etc.) I am attaching another example showing this method. The Biggest advantage is this array can be saved in spread sheet file. Also I think arrays can be manipulated easily to extract whichever elements or Subarrays needed for use. The Problem remains however what to do with the tagged Zeroes? Unfortunately Labview does this and may need to remedy this. Of Course You can Logically add NAN instead of tagged zeroes. This becomes some what easy because you are handling a 2d Array rather than 3d+ array.

Having said all this. I like the 2d Array approach as I have used this in the past and also I donot need to know the size of final data array. I can save all this valuable data in a hurry.

Good Luck!!

Mache
Good Luck!

Mache
Download All
0 Kudos
Message 11 of 13
(863 Views)
> This structure is not only complex but also very expensive in terms of
> memory and CPU usage. It is going to require that every 2D element
> has an 1D array as large as the largest array you will need for any
> one particular array 2D array element. For example:
>
> If you have a 2 D array that is 200 x 300 and most elements only need
> 10 items in the 1D array but 1 needs 50, then you will have 200 x 300
> x 50 elements or 3000000 elements instead of 600040 elements. It is
> not a very efficient way to do this.
>


>
>>You cannot create an array of arrays. You need to simply add another
>>dimension to create a 3D array. It simply isn't possible to create a
>>1D array of 2D arrays.
>>


Actually, there is a big difference between a 3D
and a 2D containing a
1D array. First, as mentioned in other suggestions, you just put a
cluster between the 1D and 2D array, and this is how make arrays of arrays.

As for the size, a 2D array has to be squared off, meaning that an m by
n array always has m x n elements. A 3D array of l by m by n has l x m
x n elements. That means that a 2D array of 1D arrays can have as
little as m x n elements allocated, or m x n x l elements plus m x n
headers when each of 1D arrays has l elements.

In otherwords, the array of arrays can have a ragged edge and when used
appropriately it will save space since each 1D array uses only what it
needs.

Greg McKaskle
0 Kudos
Message 12 of 13
(1,149 Views)
I'll have to try that, I always thought that a 2D array of 1D arrays
would use the same memory as a 3D array. That's why I suggested what
I did. If you are right, then there is no advantage in what I
suggested.

Doug De Clue

Greg McKaskle wrote in message news:<3D4B43F3.7040201@austin.rr.com>...
> > This structure is not only complex but also very expensive in terms of
> > memory and CPU usage. It is going to require that every 2D element
> > has an 1D array as large as the largest array you will need for any
> > one particular array 2D array element. For example:
> >
> > If you have a 2 D array that is 200 x 300 and most elements only need
> > 10 items in the 1D array but 1 needs 50, then you will hav
e 200 x 300
> > x 50 elements or 3000000 elements instead of 600040 elements. It is
> > not a very efficient way to do this.
> >
>
>
> >
> >>You cannot create an array of arrays. You need to simply add another
> >>dimension to create a 3D array. It simply isn't possible to create a
> >>1D array of 2D arrays.
> >>
>
>
> Actually, there is a big difference between a 3D and a 2D containing a
> 1D array. First, as mentioned in other suggestions, you just put a
> cluster between the 1D and 2D array, and this is how make arrays of arrays.
>
> As for the size, a 2D array has to be squared off, meaning that an m by
> n array always has m x n elements. A 3D array of l by m by n has l x m
> x n elements. That means that a 2D array of 1D arrays can have as
> little as m x n elements allocated, or m x n x l elements plus m x n
> headers when each of 1D arrays has l elements.
>
> In otherwords, the array of arrays can have a ragged edge and when used
> appropriately it will sav
e space since each 1D array uses only what it
> needs.
>
> Greg McKaskle
0 Kudos
Message 13 of 13
(1,149 Views)