LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

expand a 2D array horizontally

Hi
I am writing a code to insert an element into a 2D array. The problem is I can add the element only in the rows direction (vertically). I want to be able to add the element in the columns direction (horizontally). Do u know how? I attached my program here too. Thanks
0 Kudos
Message 1 of 3
(2,904 Views)
One technique is just to invert the array before adding the row and then invert it again before doing anything else with it.

Regards,
Ryan K.
0 Kudos
Message 2 of 3
(2,895 Views)
Your idea is slightly flawed, because in a typical 2D array, you cannot just add a single element without resizing the entire array.

Since you don't give a choice to add either horizontally or vertically with two buttons, how should the program decide where to add?

Could it be you want to fill the first three horizontally, then continue on the next row, and so on? (see attached modification).


Typically it is better to start with a fixed sized array of empty strings (e.g. 3x5), then use "replace array element" to enter a new value at the desired location. Constantly resizing arrays is inefficient.

Message Edited by altenbach on 03-15-2005 04:44 PM

0 Kudos
Message 3 of 3
(2,892 Views)