Consider if I have some matrices constructed as such:
A = {
{ {} , {} },
{ {} , {} }
}
B = {
{ a , b },
{ c , d }
}
C = {
{ e , f },
{ g , h }
}
...
A
serves as a matrix of empty lists. I want to be able to append B
, C
, etc. to A
, to obtain a final matrix like
A = {
{ {a, e, ...} , {b, f, ...} },
{ {c, g, ...} , {d, h, ...} }
}
How can I do this? My matrices are always square and of the same dimensions. An alternative which could also be useful is to Join
two matrices element by element, if the matrix elements of both are already lists.
Dimensions/@{A,B}
$\endgroup$A
andB
as inputs what is the desired result:{{{a}, {b}}, {{c}, {d}}}
or{{{{}, a}, {{}, b}}, {{{}, c}, {{}, d}}}
? $\endgroup$A
is simply a matrix of empty lists to append to. $\endgroup$A = {{{}, {}}, {{}, {}}};B = {{a, b}, {c, d}};cc = {{e, f}, {g, h}};
if you useTranspose[{A, B, cc}, {3, 1, 2}]
you get{{{{}, a, e}, {{}, b, f}}, {{{}, c, g}, {{}, d, h}}}
. But your post says you want{{{a, e}, {b, f}}, {{c, g}, {d, h}}}
, no? $\endgroup$