LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to convert 2D arrays to 1D array

Hi all,

I have a 2D array which contains the following information,
[00] = 2
[01] = 5
[02] = 7
[03] = 9

Is it possible for me to convert this 2D array to 1D array such that it reads the 1D array as containing the elements {2,5,7,9}? Any kind help is greatly appreciated.
0 Kudos
Message 1 of 16
(73,324 Views)
Just use index array with one index left unwired. You'll get the slice designated by the wired index.

(See attached picture. I hope I understood your problem, else please clarify).
Message 2 of 16
(73,319 Views)
Hi altenbach,

I have tried your method but seems like i can only extract the 2nd element [01] = 5 of the 2D array. My 2D array has 1 row & 8 columms. Thank you for any advice.
0 Kudos
Message 3 of 16
(73,316 Views)
Hi aiya,

Looks like you only have a 1D array not 2D.

Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 4 of 16
(73,309 Views)
Hi,

I am not too sure. Actually I have extracted a row of data from a log file & I have used the read from spreadsheet VI to extract all rows(read the entire data), But seems like it is showing a 2D array data line, and when i use an array indicator to read back the data, I noticed that the data is being read back as

[00] = 2
[01] = 5
[02] = 7
[03] = 10

So I guess it is a 2D array. When I use the index array to extract the information to convert into 1D array, I use the array indicator to read back the subarray, it shows

[0] = 5
[1] = 0
[2] = 0

May I know which part have I got it wrong?
0 Kudos
Message 5 of 16
(73,308 Views)
Well, I assumed you have a "2 colum x 5 rows" array.
(I am not familiar with your "[01] etc." nomenclature. It seems a bit ambiguous).

If it is a 2D array with 1 row and 2 colums, use the same code as I showed earlier, but wire a "0" to the upper index and leave the lower index unwired. (Or similar. Just play around a bit, there are not many possibilities). Also check the online help on "index array".

Why don't you attach a tiny VI containing your data in a diagram constant? It will make your problem clearer to us.
Message 6 of 16
(73,299 Views)
Hi,

Thanks for your help! I have tried to wire a 0 to the upper index as mentioned & it works! 🙂 Thank you!
0 Kudos
Message 7 of 16
(73,289 Views)

I have a 2D boolean array: three columns 8 rows (3 bits logic combinations from 000 to 111, I want to put them all in 1D boolean array together in series:

 

i.e

 

000

100

010

110

001

101

011

111

 

to

 

000100010110001101011111

 

How can I do that?

 
0 Kudos
Message 8 of 16
(64,366 Views)

wire te 2D array to reshape array and wire a 24 (or the product of the dimensions of the 2D array) to the dimension size input. The output will be a 1D array as requested.

 

 

Message 9 of 16
(64,355 Views)

Thaank you, it works....Smiley Wink

 
0 Kudos
Message 10 of 16
(64,327 Views)