Borrar filtros
Borrar filtros

How can I create a 3-d matrix from a 2-d matrix?

1 visualización (últimos 30 días)
zephyr21
zephyr21 el 12 de Jun. de 2016
Comentada: zephyr21 el 13 de Jun. de 2016
My matrix is an 11x14 matrix and I would like to create 2 more "pages" behind the original of the same values for a total of 3 "pages". Is there an efficient way of doing this? This needs to be done for several matrices.

Respuesta aceptada

Image Analyst
Image Analyst el 13 de Jun. de 2016
Another way is to use cat(3,...) instead of repmat():
output = cat(3, myMatrix, myMatrix, myMatrix);
or "If I have the A(:,:,2) matrix and want to replicate those values into A(:,:,1) and A(:,:,3),"
A(:,:,1) = A(:,:,2);
A(:,:,3) = A(:,:,2);

Más respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 12 de Jun. de 2016
repmat(A,1,1,3)
  4 comentarios
zephyr21
zephyr21 el 13 de Jun. de 2016
Thank you! Another question if you don't mind. If I have the A(:,:,2) matrix and want to replicate those values into A(:,:,1) and A(:,:,3), how would I do that?
Roger Stafford
Roger Stafford el 13 de Jun. de 2016
What difference does it make if all three levels end up the same?

Iniciar sesión para comentar.

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by