Deleating the 3rd dimension from a 3Dmatrix

I am unable to remove the thrird dimension from my matrix containing three dimensional elements. I got 3 idetical matrices so I want to eleminate 2 of them (a(:,:,22),a(:,:,23)).
I tride the above written code

 채택된 답변

the cyclist
the cyclist 2020년 3월 2일
편집: the cyclist 2020년 3월 2일

0 개 추천

You can remove both at once:
a(:,:,[22 23]) = [];
The main problem with your method is that after you remove the 22nd slice, the 23rd slice "moves" into the 22nd position, so there is no 23rd slice anymore. At the next iteration of the loop, when you try to remove the 23rd slice, it no longer exists.

추가 답변 (0개)

카테고리

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

제품

릴리스

R2018a

태그

질문:

2020년 3월 2일

댓글:

2020년 3월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by