Change array shapes

Joined
Apr 7, 2022
Messages
14
Reaction score
0
Hi Guys,

I think an example will make this problem easier to understand.

A1,A2,A3 are 2Dimensional arrays
Inputs:
A1=
[R1,R2,R3]
[R4, R5, R6]
[R7, R8, R9]

A2=
[G1,G2,G3]
[G4, G5, G6]
[G7, G8, G9]

A3=
[B1,B2,B3]
[B4, B5, B6]
[B7, B8, B9]

I want to produce a single array that looks like the following:
What I want to create is the following matrix:
A4 =
[R1,G1,B1]
[R2,G2,B2]
[R3,G3,B3]
[R4,G4,B4]
[R5,G5,B5]
[R6,G6,B6]
[R7,G7,B7]
[R8,G8,B8]
[R9,G9,B9]

A1,A2,A3 have a lot more rows and columns, but i think the above gives an example of what I am looking for.

Any ideas?
 
Joined
May 11, 2022
Messages
61
Reaction score
6
the problem is even if you know the desired array shape, where the values go have several options.
for the above shape and result, this would be my code
Python:
destinarray = []

for i in range(0,3):
   for j in range(0,3):
      destinarray += [A1[i][j],A2[i][j],A3[i][j]]
print(destinarray)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top