LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to 'build' one row only in a 2d array

Hi
I'd like to have a 2D array with eg 4 rows, and each time the loop iterates, it should append new data at the end of a specified row (row 0 in example) while the data in the other rows remain unchanged.
I tried all combinations of build array, replace array subset etc but for some reason I cannot get the rows to extend in length..
I want the output array in the example to be like:

2 2 2 2 2 2 2 2 2
x x x x x x x x x
x x x x x x x x x
x x x x x x x x x

Thus append the data array [2 2 2] 3 times to the first row, and leave the rest unchanged, but all I get is an empty array..

I've been struggling with this for a few hours now, but I can't find it.. Although I think it's very simple!
Or should I go fo
r an entirely different technique like clusters or so?
Can someone help me out?
0 Kudos
Message 1 of 4
(3,110 Views)

Hello Stino,

See attached diagram. Note that I use the transpose 2-D array function to flip the first column to first row.

Hope this helps.

Khalid


0 Kudos
Message 2 of 4
(3,110 Views)
Khalid,
thanks for your diagram; it didn't help me because it doesn't really do what I want, but I think the transpose 2D function is pretty interesting anyway!

I found the solution myself, but I don't know if it's clean programming considering memory etc; I first initialize an array that is big enough to conatain all data and an array containing #row elements for storing the total amount of new data written in a row.
Then I can build a specified row and by shifting the size of the data already written in that row everything gets in place..
The loop takes quite a lot of blocks and wires, comments on how to get it smaller are welcome!!
Download All
0 Kudos
Message 3 of 4
(3,110 Views)
Hi,

Arrays can only be "square". That means when the first row grows, all the
other rows are filled with zero's. You'll have to use an array of clusters
with arrays to make it work.

Regards,

Wiebe.



"stino" wrote in message
news:506500000008000000E6D90000-1079395200000@exchange.ni.com...
> Hi
> I'd like to have a 2D array with eg 4 rows, and each time the loop
> iterates, it should append new data at the end of a specified row (row
> 0 in example) while the data in the other rows remain unchanged.
> I tried all combinations of build array, replace array subset etc but
> for some reason I cannot get the rows to extend in length..
> I want the output array in the example to be like:
>
> 2 2 2 2 2 2 2 2 2
> x x x x x x x x x
> x x x x x x x x
x
> x x x x x x x x x
>
> Thus append the data array [2 2 2] 3 times to the first row, and leave
> the rest unchanged, but all I get is an empty array..
>
> I've been struggling with this for a few hours now, but I can't find
> it.. Although I think it's very simple!
> Or should I go for an entirely different technique like clusters or
> so?
> Can someone help me out?
0 Kudos
Message 4 of 4
(3,110 Views)