필터 지우기
필터 지우기

Index of non empty cells in a cell array

조회 수: 10 (최근 30일)
José Pereira
José Pereira 2017년 12월 8일
편집: KL 2017년 12월 8일
Hi, i have a cell array like this. How can i know the index of the non empty cells? In this case the result should be index=[1 1 0].(Please note that i want the index, not what isinside the cell)
1×3 cell array
{[1]} {[1]} {0×0 double}

채택된 답변

Birdman
Birdman 2017년 12월 8일
~cellfun(@isempty,x)

추가 답변 (1개)

KL
KL 2017년 12월 8일
편집: KL 2017년 12월 8일
~cellfun(@isempty,C)
or
~cellfun('isempty',C)
The latter is faster (when run for 100000 iteration), so prefer that if you have a larger cell array.
Elapsed time is 1.224846 seconds.
Elapsed time is 0.301964 seconds.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by