Create a multidimensional array and fill it with n Matrix of the same type

17 visualizaciones (últimos 30 días)
Hello Guys,
lets say I have Matrix A = [1 2 3; 4 5 6; 7 8 9] and I want to create a multidimensional Array of size n. Now each page of the multi array should contain the Matrix A. Can somebody give me a hint without using a loop. Would be glad the get some help.
  1 comentario
Lant3rn
Lant3rn el 31 de Ag. de 2021
I got the answer by myself :-): A = repmat(A,[1 1 n]) will do the job. If anyone has another Idea still interested in reading it :-)

Iniciar sesión para comentar.

Respuestas (1)

Pratyay Pande
Pratyay Pande el 3 de Sept. de 2021
The approach that @Lant3rn mentioned is correct and also one that is recommended.
Another approach to do the same without using repmat is:
A = A(:,:,ones(1,n));

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by