I have Multidimensional Arrays, but I need of a reshaped matrix, indexing columns of each "dimension".
The number of arrays and number of rows can change according to the user, like that:
A (1:x, 1:3, 1:y) if x= 3 and y = 2
A(:,:,1)= [1 2 3
4 5 6
7 8 9];
A(:,:,2)= [10 11 12
13 13 15
16 17 18];
Matlab answer
B = Reshape (A,x*y,3)
B= [1 3 11
4 6 13
7 9 17
2 10 12
5 13 15
8 16 18];
I need the answer:
B= [1 2 3
4 5 6
7 8 9
10 11 12
13 14 15
16 17 18];
Thank for your help

 채택된 답변

Stephen23
Stephen23 2018년 7월 30일

1 개 추천

reshape(permute(A,[1,3,2]),x*y,3)

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

릴리스

R2017a

질문:

2018년 7월 30일

댓글:

2018년 7월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by