How to reshape and reorder a 5D arrays to 4D arrays?

조회 수: 1 (최근 30일)
Cyrus GT Chen
Cyrus GT Chen 2019년 6월 4일
댓글: Cyrus GT Chen 2019년 6월 5일
Hello
I'm managing 192x192x20x8x2 dimension arrays. In my problem, I need to reshape the 5D array to 4D, and re-ordering the third dimension.
For example, I need to reorder the 5D arrays from [ : , : , 1 : 2 : 39 , : , 1 ] and [ : , : , 2 : 2 : 40 , : , 2 ] to the 4D arrays [ : , : , 1 : 40 , : ]
How could I do it? Thanks a lot!

채택된 답변

Andrei Bobrov
Andrei Bobrov 2019년 6월 4일
Let A - your 5D array:
k = size(A);
out = zeros(k(1:end-1).*[1,1,2,1]);
out(:,:,1:2:end,:) = A(:,:,:,:,1);
out(:,:,2:2:end,:) = A(:,:,:,:,2);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by