ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

adding dimension to 2d array

Have 2D array completed:

1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8

Need to add dimension:

1  1 2 3 4 5 6 7 8
1  1 2 3 4 5 6 7 8
2  1 2 3 4 5 6 7 8
etc
0 Kudos
Message 1 of 14
(5,757 Views)
Is that first column supposed to be the "page" for the 3D array?

A Build Array is what you need to use.
0 Kudos
Message 2 of 14
(5,750 Views)
Or if you are creating a constant you can right click on it and select add dimension.
Jim

LV 2020
0 Kudos
Message 3 of 14
(5,744 Views)
Thank you for the quick replies.
One problem remains, I do not have a second 2D array for the build function.
I simply have a dimension value, which varies of course.
0 Kudos
Message 4 of 14
(5,740 Views)

@markfranklin wrote:
One problem remains, I do not have a second 2D array for the build function.

If you have a 1D array then make it into a 2D array using the same function. Please read the documentation on Build Array.


I simply have a dimension value, which varies of course.

I have no idea what this means.

0 Kudos
Message 5 of 14
(5,737 Views)
The third dimension (shown as 1 and 2 on far left of first example) is simply a card number that needs to be stored with the 2D array of data.
I was hoping that this card number could be a third dimension to ease look-ups later.
0 Kudos
Message 6 of 14
(5,731 Views)
Are you actually wanting to create a 3 dimensional array?  Or do you just want to add another row (or column) to a 2 dimensional array?
0 Kudos
Message 7 of 14
(5,714 Views)
I believe that a 3D array would serve me best.
0 Kudos
Message 8 of 14
(5,708 Views)
The thing you have to keep in mind with multi-dimensional arrays is that you can't have different number of elements for each row/column/page. This means that if you had a 2D array, you can't have, for example, row1 have 5 elements and row2 have 7 elements. Each row has to have the same number of columns. (The equivalent is true for columns). For a 3D array, each page has to have the same size 2D array. Thus, if you want to have the first page with a 2D array of 2 rows and 8 columns, and the second page be a 2D array of 1 row and 8 columns, you can't do that. The second page must be the same size - 2 rows and 8 columns.

If this is not acceptable for your application, then you must change your data structure. In your initial post you provided a small snippet, which seemed to imply that you were adding pages, with each page being the same size. Is this true?
0 Kudos
Message 9 of 14
(5,701 Views)
Thank you.

An instrument VI outputs a 2D array for each card in the instrument (card number can vary).
Each time it outputs a 2D array, there is a card number associated with the data.
I had thought that it would be best to add a dimension for including the card number.
Perhaps that is a bad idea?

I am beginning to think that building or appending the 2D array to more simply include the the card number.
0 Kudos
Message 10 of 14
(5,692 Views)