How to remove a 2d array from a 3d array?

조회 수: 5 (최근 30일)
N/A
N/A 2021년 3월 28일
댓글: N/A 2021년 3월 28일
I want to remove all 2d arrays containing all zeros, but the size of the 3d array that I am working with changes each time I remove a 2d array. How do I do this? My sample code that does not quite get the job done is below.
Q = length(LargeArray);
ii = 1;
while ii < Q
if ~all(any(LargeArray(:,:,ii)))
LargeArray(:,:,ii)=[];
end
Q = size(Large,3);
ii = ii + 1;
end

채택된 답변

Matt J
Matt J 2021년 3월 28일
LargeArray = LargeArray(:,:, any(LargeArray,[1,2]));
  댓글 수: 1
N/A
N/A 2021년 3월 28일
Thank you. Elegant. Short and sweet.

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

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by