06-12-2024 04:36 PM
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.
Solved! Go to Solution.
06-12-2024 05:15 PM
Maybe like this?
(note that the "built array" inside the loop is in concatenate modes (right-click...)
06-13-2024 01:02 AM
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…
06-13-2024 08:21 AM
This works
06-13-2024 08:41 AM
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.
06-13-2024 09:15 AM
Thanks guys. I used the 4 transpose operations because performance wont be an issue. But thanks to all of you.
06-13-2024 09:58 AM - edited 06-13-2024 10:00 AM
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!)
06-13-2024 09:43 PM
@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.
06-13-2024 10:42 PM - edited 06-13-2024 10:48 PM
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"
(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)
06-14-2024 02:06 AM
@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"
(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.