LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create 2D array from several 2D arrays

Say I have the following 2D arrays:

A 1
B 2
C 3
D 4
E 5

 

A 11
C 22
D 32
F 42
G 53

 

A 12
D 23
E 55
F 44
H 56

 

 I want to add on to create the final array where the * are empty spaces: 

A 1 11 12
B 2 ** **
C 3 22 **
D 4 32 23
E 5 ** 55
F * 42 44
G * 53 **
H * ** 56

 

How would one proceed? First I was thinking of creating a 1D array of the first column, called say 1stcol, appending them but also removing duplicates. 

 

Then I'd create a while loop, indexing each element of 1st col, where if element of 1stcol = element of 2D array 1 1st col, append element to the first row, and if not found then put empty string. 

 

I don't know if that makes sense but please let me know of any ideas. 

0 Kudos
Message 1 of 4
(1,171 Views)

Hi Jody,

 

Depending upon how you are getting this data, solution may change but below is what I could think of based on what you have written. You can change the data type from string to numbers or vise versa, if needed.

 

 

Also, Map VIs can be used to better organize your data if the application requires.

Build 2D Array_Strings_M2.png

Build 2D Array_M1.png

 

Hope this gives you some ideas to start with. 

0 Kudos
Message 2 of 4
(1,137 Views)

You cannot have empty spaces in numerics, so I assume that all output data should be strings, i.e. a simple 2D array of strings.

 

Our help is typically faster of you would create and attach a small VI that has a typical inputs as diagram constants so we don't need to tediously create something from scratch. Our time is valuable!

 

Also be careful to avoid any special cases, for example can you guarantee that all input array have exactly the same number of rows or can the sizes vary? Do we know all possible letters (first column) from the beginning?

0 Kudos
Message 3 of 4
(1,093 Views)

Assuming all input array have the same size, I made it a 3D array, one plane per input. If the number of rows can differ, we can make it a 1D array of clusters where each cluster contains a 2D array with N rows and two columns, so modify as needed).

 

altenbach_0-1668621706997.png

 

0 Kudos
Message 4 of 4
(1,085 Views)