0

What should I do to convert a matrix of matrices to a non-nested matrix?

$\left( \begin{array}{cc} \left( \begin{array}{cc} {a_1} & {b_1} \\ {c_1} & {d_1} \\ \end{array} \right) & \left( \begin{array}{cc} {a_2} & {b_2} \\ {c_2} & {d_2} \\ \end{array} \right) \\ \left( \begin{array}{cc} {a_3} & {b_3} \\ {c_3} & {d_3} \\ \end{array} \right) & \left( \begin{array}{cc} {a_4} & {b_4} \\ {c_4} & {d_4} \\ \end{array} \right) \\ \end{array} \right)\to \left( \begin{array}{cccc} {a_1} & {b_1} & {a_2} & {b_2} \\ {c_1} & {d_1} & {c_2} & {d_2} \\ {a_3} & {b_3} & {a_4} & {b_4} \\ {c_3} & {d_3} & {c_4} & {d_4} \\ \end{array} \right)$

Anixx
  • 3,585
  • 1
  • 20
  • 32

1 Answers1

4

To expand on the comment, this is exactly what ArrayFlatten is designed to do. Straight from the documentation:

ArrayFlatten[{{$m_{11}$,$m_{12}$,...},{$m_{21}$,$m_{22}$,...},...}] creates a single flattened matrix from a matrix of matrices $m_{ij}$

So for your example,

sub[i_] = Partition[Table[Alphabet[][[j]][i], {j, 4}], 2];
m = Partition[Table[sub[i], {i, 4}], 2];
flat = ArrayFlatten[m];
MatrixForm /@ {m, flat}

enter image description here

bRost03
  • 2,072
  • 8
  • 14