필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to delete the columns of a cell array if the last elements of the columns are zero

조회 수: 1 (최근 30일)
H R
H R 2019년 3월 2일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi All,
I have a large cell arry PP with three rows and lots of columns as follows:
'A.txt' 'A2.bmp' 'A5.jpg'
1.1 1.3 1.4
1 1 0
How to delete the columns whose last elements are zero. After deleting the columns PP should look like this
'A.txt' 'A2.bmp'
1.1 1.3
1 1
Thanks.

답변 (1개)

Luna
Luna 2019년 3월 2일
Hi,
You can use this:
myArray = {'A','B','C','D'; 2 2 4 0;1 1 5 2; 1 1 6 0; 1 1 0 1};
newArray = myArray(:,~([myArray{end,:}] == 0))

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by