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$ – Fortsaint Jun 21 '19 at 20:47A
andB
as inputs what is the desired result:{{{a}, {b}}, {{c}, {d}}}
or{{{{}, a}, {{}, b}}, {{{}, c}, {{}, d}}}
? $\endgroup$ – kglr Jun 22 '19 at 0:45A
is simply a matrix of empty lists to append to. $\endgroup$ – Kai Jun 22 '19 at 2:20A = {{{}, {}}, {{}, {}}};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$ – kglr Jun 22 '19 at 3:10