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

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일

0 개 추천

LargeArray = LargeArray(:,:, any(LargeArray,[1,2]));

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

제품

릴리스

R2020b

태그

질문:

N/A
2021년 3월 28일

댓글:

N/A
2021년 3월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by