MATLAB Answers

Remove dimension from high dimensional array

13 views (last 30 days)
Hi all, I have a 8D array with size 10 8 10 8 6 7 8 9, and I want to remove one specific dimension (the one with 6 elements), obtaining a 7D array. There exist a Matlab function to do it?

Accepted Answer

Scott MacKenzie
Scott MacKenzie on 21 Aug 2021
Try this...
M = rand(10, 8, 10, 8, 6, 7, 8, 9);
whos
Name Size Bytes Class Attributes M 8-D 154828800 double
M(:,:,:,:,2:end,:,:,:) = [];
N = squeeze(M);
whos
Name Size Bytes Class Attributes M 8-D 25804800 double N 7-D 25804800 double

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by