WLJS LogoWLJS Notebook

ArrayFlatten

ArrayFlatten[{{m11, m12, ...}, {m21, m22, ...}, ...}] creates a single flattened matrix from a matrix of matrices mij.

ArrayFlatten[a, r] flattens out r pairs of levels in the array a.

Examples

Flatten a block matrix:

ArrayFlatten[{{{{1, 2}}, {{3, 4}}}, {{{5, 6}}, {{7, 8}}}}]
(* {{1, 2, 3, 4}, {5, 6, 7, 8}} *)

Create a block diagonal matrix:

ArrayFlatten[{{IdentityMatrix[2], 0}, {0, IdentityMatrix[3]}}]

Please visit the official Wolfram Language Reference for more details.

On this page