How can i find which value of a cell equals to 1?

7 ビュー (過去 30 日間)
Volkan Yangin
Volkan Yangin 2016 年 10 月 7 日
コメント済み: Jakub Rysanek 2016 年 10 月 9 日
Hi everbody,
I have a cell array includes [] and 1 elements and i want to find which cell equals to 1. (For ex. 220. cell equals 1.)
Thanks...

採用された回答

Massimo Zanetti
Massimo Zanetti 2016 年 10 月 7 日
If in your cell you have only [] or 1 elements, this works.
C={1,[],[],1,[],1}
%get indeces of 1s
OnesInC = find(~cell2mat(cellfun( @(x) isempty(x) , C , 'UniformOutput' , false )))
Otherwise, let me know.
  2 件のコメント
Volkan Yangin
Volkan Yangin 2016 年 10 月 7 日
It works succesfully. Thanks. :)
Jakub Rysanek
Jakub Rysanek 2016 年 10 月 9 日
Or you can do it 20x times:
find(~cellfun('isempty',C));

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by