How to reshape an M x (aN) matrix into a (aM) x (N) matrix in MATLAB?
조회 수: 3 (최근 30일)
이전 댓글 표시
Hey everyone,
I want to reshape an M x (aN) matrix into a (aM) x (N) matrix in MATLAB without using nested for loops?
An example transformation is given below if a=3. (Each square is given with a size of M x N)

댓글 수: 0
채택된 답변
Bruno Luong
2022년 3월 28일
편집: Bruno Luong
2022년 3월 28일
Use permute
m = 3;
n = 2;
a = 4;
A = reshape(zeros(m,n)+reshape(1:a,[1 1 a]),[m n*a]);
A
B = reshape(permute(reshape(A,[m n a]),[1 3 2]),[m*a n])
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!