How to construct a 3x9 matrix E from a 3x3x3 matrix D, where D(x,y,:) is the column of E?

조회 수: 6 (최근 30일)
A = [1 2 3; 4 5 6; 7 8 9];
B = [11 22 33; 44 55 66; 77 88 99];
C = [111 222 333; 444 555 666; 777 888 999];
D = cat(3,A,B,C);
How to construct a 3x9 matrix E, where E(:,1) = D(1,1,:), E(:,2)=D(1,2,:), E(:,3)=D(1,3,:), ..., E(:,9)=D(3,3,:)?
What if D is a 3 x m x n matrix? How to construct a 2D (3x mn) matrix E from D, where D(x,y,:) becomes the column of E? Thank you.

답변 (1개)

Image Analyst
Image Analyst 2021년 10월 8일
A = [1 2 3; 4 5 6; 7 8 9];
B = [11 22 33; 44 55 66; 77 88 99];
C = [111 222 333; 444 555 666; 777 888 999];
D = cat(3,A,B,C)
E = [reshape(D(:, :, 1), [], 1), reshape(D(:, :, 2), [], 1), reshape(D(:, :, 3), [], 1)]
E =
1 11 111
4 44 444
7 77 777
2 22 222
5 55 555
8 88 888
3 33 333
6 66 666
9 99 999

카테고리

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