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

조회 수: 1 (최근 30일)
zephyr21
zephyr21 2016년 6월 12일
댓글: zephyr21 2016년 6월 13일
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.

채택된 답변

Image Analyst
Image Analyst 2016년 6월 13일
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);

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 6월 12일
repmat(A,1,1,3)
  댓글 수: 4
zephyr21
zephyr21 2016년 6월 13일
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 2016년 6월 13일
What difference does it make if all three levels end up the same?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by