converting 2d matrix to 3d

조회 수: 4 (최근 30일)
Joe M
Joe M 2014년 6월 25일
댓글: Walter Roberson 2016년 10월 4일
Can anyone help me with making a 2D matrix into a 3D matrix?
I have a (71680 x 8) 2d matrix and I need to make a 3D matrix of dimensions (512 x 8 x 140) I need to take (512 x 8) consecutive matrices by row for 140 layers.
Can anyone help me with this? I really appreciate any help

채택된 답변

Titus Edelhofer
Titus Edelhofer 2014년 6월 25일
HI Joe,
if I'm not mistaken, it should be
permute(reshape(X, 512, 140, 8), [1 3 2]);
Titus
  댓글 수: 3
Titus Edelhofer
Titus Edelhofer 2014년 6월 25일
Hi Joe,
thanks. Could you please accept the answer then so others know it's already answered?
Titus
Christopher Ndehedehe
Christopher Ndehedehe 2014년 9월 2일
Answer is great. it helped as well. Thanks Joe

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

추가 답변 (1개)

amit
amit 2016년 10월 3일
permute(reshape(X, 512, 140, 8), [1 3 2]); what is [1 3 2] stands for?
  댓글 수: 1
Walter Roberson
Walter Roberson 2016년 10월 4일
"B = permute(A,order) rearranges the dimensions of A so that they are in the order specified by the vector order"
In your case it would rearrange reshape(X, 512, 140, 8) to be 512 x 8 x 140 by rearranging the elements. What was previously indexed at location (I,J,K) would be at location (I,K,J) in the new array.

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

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by