Suppose I wanted to generate a 5x4 matrix. A good way to do it is to write the following commands:
\[
\begin{tikzpicture}
\matrix(m) [matrix of nodes, ampersand replacement=\&, row sep=1ex, column sep=1ex, nodes in empty cells, nodes={shape=rectangle,minimum height=3ex, anchor=center},] {
$A_{11}$ \& $A_{12}$ \& $A_{13}$ \& $A_{14}$ \\
$A_{21}$ \& $A_{22}$ \& $A_{23}$ \& $A_{24}$ \\
$A_{31}$ \& $A_{32}$ \& $A_{33}$ \& $A_{34}$ \\
$A_{41}$ \& $A_{42}$ \& $A_{43}$ \& $A_{44}$ \\
$A_{51}$ \& $A_{52}$ \& $A_{53}$ \& $A_{54}$ \\
};
\node[fit= (m-1-1.north west) (m-5-4.south east), left delimiter={[}, right delimiter={]},inner sep=1ex] {};
\end{tikzpicture}
\]
(I use tikz because it allows me to format individual matrix elements and insert graphics).
This can get rather tiring if I have to populate a 10x9 matrix. The idea is to write a
NewDocumentCommand with three inputs: the letter denoting the matrix, the number of rows and the number of columns. Using expl3 I should be able to generate the matrix contents. Then I should be able to write something like,
\begin{tikzpicture}
\matrix(m) [matrix of nodes, ampersand replacement=\&, row sep=1ex, column sep=1ex, nodes in empty cells, nodes={shape=rectangle,minimum height=3ex, anchor=center},] {
\matrixcontents
};
\node[fit= (m-1-1.north west) (m-#2-#3.south east), left delimiter={[}, right delimiter={]},inner sep=1ex] {};
\end{tikzpicture}
where \matrixcontents contains
$A_{11}$ \& $A_{12}$ \& $A_{13}$ \& $A_{14}$ \\
$A_{21}$ \& $A_{22}$ \& $A_{23}$ \& $A_{24}$ \\
$A_{31}$ \& $A_{32}$ \& $A_{33}$ \& $A_{34}$ \\
$A_{41}$ \& $A_{42}$ \& $A_{43}$ \& $A_{44}$ \\
$A_{51}$ \& $A_{52}$ \& $A_{53}$ \& $A_{54}$ \\
and #2, #3 are respectively the number of rows, number of columns arguments of
the NewDocumentCommand (in this example #1 is the letter A).
I am an absolute beginner with expl3 and so I have no idea how to generate \matrixcontents.



