The concatenation[] operator will work only in two dimensions, for example [a b], to combine horizontally or [a; b]to concatenate vertically.To create matrices with higher dimensions , you can use reshapeor initialize the matrix of the desired size, and then fill it with your values. For example, you can do this:
A = reshape([...], [3 4 4]); % Where "..." is what you have above
Or that:
A = zeros(3, 4, 4); % Preallocate the matrix
A(:) = [...]; % Where "..." is what you have above
source
share