convert a 2D matrix into 3D matrix

조회 수: 5 (최근 30일)
Dwight
Dwight 2012년 1월 4일
Can anyone help me with making a 2D matrix into a 3D matrix?
I have a (105504 x 3) 2d matrix and I need to make a 3D matrix of dimensions (6 x 3 x 17584) I need to take (6 x 3) consecutive matrices by row for 17584 layers.
Can anyone help me with this? I really appreciate any help
  댓글 수: 1
Dwight
Dwight 2012년 1월 5일
Thank you @andrei and @Walter!!! Walter, your code gave me a 3D matrix (17584x6x3). Andrei, your code worked perfectly (3D matrix (6x3x17584), Thank you for the help guys, you are awesome!!!
keep it up!!!

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

채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 1월 4일
a - your array (105504 x 3)
out = permute(reshape(a.', 3,6,[]),[2 1 3]);
  댓글 수: 1
Dwight
Dwight 2012년 1월 5일
Andrei, your code worked perfectly (3D matrix (6x3x17584)). Thank you very much.

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2012년 1월 4일
Please try
B = permute(reshape(A, 6, [], 3),[2 1 3]);
  댓글 수: 1
Dwight
Dwight 2012년 1월 5일
Walter, your code gave me a 3D matrix (17584x6x3).
Andrei's code gave me the correct dimensions I needed, but I appreciate your quick and expert response.
Thank you much

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by