I want to write MATLAB code that includes an array consisting of all $2 \times 2$ square matrices whose elements are elements of $\Bbb{Z}_2= \{0,1\}$, e.g.,
$$ \begin{pmatrix} 0 & 0 \\ 0 & 0 \end{pmatrix},\quad \begin{pmatrix} 1 & 0 \\ 0 & 0 \end{pmatrix},\quad \begin{pmatrix} 0 & 1 \\ 0 & 0 \end{pmatrix},\quad \begin{pmatrix} 0 & 0 \\ 1 & 0 \end{pmatrix},\quad \begin{pmatrix} 0 & 0 \\ 0 & 1 \end{pmatrix},\quad \begin{pmatrix} 1 & 1 \\ 0 & 0 \end{pmatrix},\quad \cdots$$
And how can I generalize the same thing with $\Bbb{Z}_2$ for $n \times n$ square matrix? Please help!
The MATLAB code below generates a $50 \times 50$ array in which each element is a random $100 \times 100$ square binary matrix. You can just change the parameters $n,I$ and $J$ as you wish.