Following this question [defining-nodes-of-a-matrix-programmatically](https://tex.stackexchange.com/questions/437267/defining-nodes-of-a-matrix-programmatically/), I was able to precise more of what I am trying to achieve. Sorry that I was way too general in the first question.
Here is the new MWE. Reading the first question ([here](https://tex.stackexchange.com/questions/437267/defining-nodes-of-a-matrix-programmatically/)) is absolutely essential.

My end goal is to define node positioning in a matrix, the nodes are not placed at the same distance of each others.

I am able to define the dimensions of each node with append style with method 1, but would like to achieve it with method 2 or 3 (or a similar method). For some reason, looping is not working properly for appending to style : maybe I need to buffer the information somewhere ? 

```
\documentclass[border=2mm,tikz]{standalone}

\usetikzlibrary{matrix}
\usepackage{xinttools}

\begin{document}
\tikzset{dimensionsBigBox/.style={
        minimum height=3cm,
        rectangle, 
        fill=none, draw=blue,
        text depth=0.5em, text height=1em,
}}

\tikzset{dimensionsSmallBox/.style={
        minimum height=1cm,
        rectangle, 
        fill=none, draw=red,
        text depth=0.5em, text height=1em,
}}

\tikzset{
mygridmatrix/.style={
    matrix of nodes, 
    row sep=-\pgflinewidth, column sep=-\pgflinewidth, 
    nodes={draw}, 
    nodes in empty cells,
},
}

\iftrue
    % Method 1 : Block of hardcoded definition of the nodes
    \tikzset{mygridmatrix/.append style={row 1 column 1/.style={nodes={dimensionsSmallBox}}}}
    \tikzset{mygridmatrix/.append style={row 1 column 2/.style={nodes={dimensionsSmallBox}}}}
    \tikzset{mygridmatrix/.append style={row 1 column 3/.style={nodes={dimensionsSmallBox}}}}
    \tikzset{mygridmatrix/.append style={row 2 column 1/.style={nodes={dimensionsBigBox}}}}
    \tikzset{mygridmatrix/.append style={row 2 column 2/.style={nodes={dimensionsBigBox}}}}
    \tikzset{mygridmatrix/.append style={row 2 column 3/.style={nodes={dimensionsBigBox}}}}
    \tikzset{mygridmatrix/.append style={row 3 column 1/.style={nodes={dimensionsSmallBox}}}}
    \tikzset{mygridmatrix/.append style={row 3 column 2/.style={nodes={dimensionsSmallBox}}}}
    \tikzset{mygridmatrix/.append style={row 3 column 3/.style={nodes={dimensionsSmallBox}}}}
\fi

\iffalse
    % Method 2 : Append style and loop with xintFor ==> only apply the last style of the loop iteration
    %\xintForpair #1#2 in  {(1,dimensionsBigBox), (2,dimensionsSmallBox), (3,dimensionsBigBox),(4,dimensionsSmallBox), (5,dimensionsSmallBox), (6,dimensionsSmallBox), (7,dimensionsBigBox), (8,dimensionsBigBox), (9,dimensionsBigBox), (2,dimensionsSmallBox)} \do {
    \xintForpair #1#2 in  {(1,dimensionsBigBox), (2,dimensionsSmallBox), (3,dimensionsBigBox),(4,dimensionsSmallBox), (5,dimensionsSmallBox), (6,dimensionsSmallBox), (7,dimensionsBigBox), (8,dimensionsBigBox), (9,dimensionsBigBox)} \do {
        %Set style #2 for node  #1 \\
        \pgfmathsetmacro\row{int(div(#1-1,3)+1)}
        \pgfmathsetmacro\col{int(mod(#1-1,3)+1)}
        \tikzset{mygridmatrix/.append style={row \row\space column \col/.style={nodes={#2}}}}
        }
\fi

\iffalse
    % Method 3 : Append style and loop with foreach ==> doesn't apply any style
    \foreach \x/\y  in  {1/dimensionsBigBox, 2/dimensionsBigBox, 3/dimensionsBigBox, 4/dimensionsSmallBox, 5/dimensionsSmallBox, 6/dimensionsSmallBox, 7/dimensionsBigBox, 8/dimensionsBigBox, 9/dimensionsBigBox}{
        %Set style \y for node  \x \\
        \pgfmathsetmacro\row{int(div(\x-1,3)+1)}
        \pgfmathsetmacro\col{int(mod(\x-1,3)+1)}
        \tikzset{mygridmatrix/.append style={row \row\space column \col/.style={nodes={\y}}}}
    }
\fi

\begin{tikzpicture}
    \matrix (m) [mygridmatrix]
    {
        1&2&3\\
        4&5&6\\
        7&8&9\\
    };
\end{tikzpicture}

\end{document}

```