LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Combine 3 2D arrays in a certain way

Solved!
Go to solution

Let's say for example I have the following 3 arrays:

123

456

789

 

and

 

321

654

987

 

and

 

213

546

768

 

and I want to combine them to the following array:


123 321 213

456 654 546

789 987 768

What could I do? I thought about transposing each of them first and then using build array, but that doesn't seem to work.

0 Kudos
Message 1 of 11
(863 Views)

Maybe like this?

 

(note that the "built array" inside the loop is in concatenate modes (right-click...)

 

altenbach_0-1718230458901.png

 

Message 2 of 11
(849 Views)
Solution
Accepted by topic author alainschaerer

Hi Alain,

 


@alainschaerer wrote:

I thought about transposing each of them first and then using build array, but that doesn't seem to work.


Transpose each input array, BuildArray with 3 inputs in concat mode, transpose the output…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 11
(815 Views)

This works

a.png

Message 4 of 11
(803 Views)

I would go with my solution. A single FOR loop is probably preferred over four transpose operations, even though the compiler will probably optimized it into similar binary code.

Message 5 of 11
(795 Views)

Thanks guys. I used the 4 transpose operations because performance wont be an issue. But thanks to all of you.

0 Kudos
Message 6 of 11
(783 Views)

My comment was based on code simplicity, readability, programming speed, and diagram area, even though performance might be similar. 🙂

 

Once you have the concatenate operation, placing a FOR loop around it is more than 3x faster than herding four(!) transpose primitives. 😮

 

(That's like tripling your hourly wage!)

0 Kudos
Message 7 of 11
(766 Views)

@altenbach wrote:

My comment was based on code simplicity, readability, programming speed, and diagram area, even though performance might be similar. 🙂

 

Once you have the concatenate operation, placing a FOR loop around it is more than 3x faster than herding four(!) transpose primitives. 😮

 

(That's like tripling your hourly wage!)


I really don't understand your code.  Neither the inputs, nor the outputs match what the OP requested.

0 Kudos
Message 8 of 11
(735 Views)

Since I did not like tediously entering 27 values, I entered 9 unique values in a 3x3 pattern and modified these to created A, B, C in three wires (and display in three indicators for reference). Then I used the data of ABC to create the requested arrangement,

 

So, three 3x3 2D arrays merged into one new 2D array as requested. Ignore the values, it's all about the final arrangement. 😄

 

Task from the subject line: "Combine 3 2D arrays in a certain way"

 

altenbach_1-1718336511932.png

 

 

(Your snippet is too new for me to look at and see what the default values are, but I was puzzled by the orange color for integers)

 

 

0 Kudos
Message 9 of 11
(727 Views)

@altenbach wrote:

Since I did not like tediously entering 27 values, I entered 9 unique values in a 3x3 pattern and modified these to created A, B, C in three wires (and display in three indicators for reference). Then I used the data of ABC to create the requested arrangement,

 

So, three 3x3 2D arrays merged into one new 2D array as requested. Ignore the values, it's all about the final arrangement. 😄

 

Task from the subject line: "Combine 3 2D arrays in a certain way"

 

altenbach_1-1718336511932.png

 

 

(Your snippet is too new for me to look at and see what the default values are, but I was puzzled by the orange color for integers)

 

 


I saw it as 9 values in 3 arrays of size 3x1.

0 Kudos
Message 10 of 11
(709 Views)