MATLAB Answers

Remove dimension from high dimensional array

조회 수: 13(최근 30일)
Francesco Porretta
Francesco Porretta 2021년 8월 21일
댓글: Scott MacKenzie 2021년 8월 21일
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?

채택된 답변

Scott MacKenzie
Scott MacKenzie 2021년 8월 21일
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
  댓글 수: 2
Scott MacKenzie
Scott MacKenzie 2021년 8월 21일
You're welcome. Good luck.

댓글을 달려면 로그인하십시오.

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by