How to reshape and reorder a 5D arrays to 4D arrays?
1 view (last 30 days)
Show older comments
Cyrus GT Chen
on 4 Jun 2019
Commented: Cyrus GT Chen
on 5 Jun 2019
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!
0 Comments
Accepted Answer
Andrei Bobrov
on 4 Jun 2019
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);
More Answers (0)
See Also
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!