Some courses and learning paths on NI Learning Center may not appear on learner dashboards. Our team is actively investigating.

If you encounter access issues, please contact services@ni.com and include the learner’s name, email, service ID or EA number, and the list of required courses.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Merge Two 2D Arrays By Alternating Columns

Solved!
Go to solution

I'm trying to do some simple data manipulation to be used in a csv test report. 

 

Overview:

Input:

Array A =

[ A1 A2 A3 A4]

[ A1 A2 A3 A4]

 

Array B =

[ B1 B2 B3 B4]

[ B1 B2 B3 B4]

 

Desired Output:

[ A1 B1 A2 B2 A3 B3 A4 B4]

[ A1 B1 A2 B2 A3 B3 A4 B4]

 

 

I have two inputs, first is a 2d array of data containing for test data at 7 different points during the test. This data has been converted from double to string.

 

I also have a 2d array of booleans that that initially only has 6 different data points since the first test point does not have a pass/fail critira. Booleans are converted to strings and relabled as "pass" or "fail" and then a blank row is added at the top so that the two array's are the same size.

 

Sample code below

AMAGIS_1-1754669263611.png

 

With the index for "index array" fixed and index fixed for 'insert into array', i can successfully get the first column of Array B inserted into index 1 of array A. however when i try to programmatically connect the index of "index array" (0, 1, 2, 3) and change the insert array index to 1,3,5,7), it doesn't seem to work as i would expect.  

 

Thoughts?

 

 

0 Kudos
Message 1 of 8
(903 Views)

first problem

 

  • Your attached VI does not seem to have any resemblance to the "merge" problem.
  • Your arrays are ambiguous because all rows are the same and we cannot e.g. tell which A1 ends up where.

second problem

 

  • When attaching code, make sure that all controls have reasonable default data. Your code has all empty arrays. Once there is default data, tell us what result you expect (e.g. by manually filling default data into the indicator).
  • Please don't maximize the diagram to the screen!
  • Seems very convoluted, for example the upper two "transpose" cancel each other out, right?

 

 

0 Kudos
Message 2 of 8
(896 Views)
Solution
Accepted by topic author AMAGIS

Making some assumptions, here's a potential "merge" solution (using "interleave 1D arrays")

 

altenbach_0-1754671230479.png

 

Message 3 of 8
(888 Views)

@AMAGIS wrote:

I have two inputs, first is a 2d array of data containing for test data at 7 different points during the test. This data has been converted from double to string.

...

Thoughts?


Did you mean "four" (4) instead of "for"? Does the 2D array have 4 rows and seven columns?

0 Kudos
Message 4 of 8
(881 Views)

See if this can give you some ideas....

 

altenbach_0-1754673091553.png

 

Message 5 of 8
(871 Views)

Thanks everyone. The interleave in a for loop is all I needed. Consider this solved.

0 Kudos
Message 6 of 8
(795 Views)

Please don't forget to give kudos for those who helped you ! 

Message 7 of 8
(790 Views)

@AMAGIS wrote:

Thanks everyone. The interleave in a for loop is all I needed. Consider this solved.


Please mark the solution.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 8 of 8
(735 Views)