フィルターのクリア

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 Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by