Finding/counting logical ones in a cell array

7 ビュー (過去 30 日間)
Levente Gellért
Levente Gellért 2021 年 6 月 30 日
コメント済み: Levente Gellért 2021 年 6 月 30 日
Dear Experts, I am trying to count , how many logical ones I have in my cell array.
I was trying these way's:
idx = find([mycell{:}] == 1);
idx=cellfun(@(c)any(c==1),mycell);
idx=cellfun(@(c)any(c>0),mycell);
These do not work.
Please, find a example cell array attached and share your opinions!
MAny thanks
lg

採用された回答

Walter Roberson
Walter Roberson 2021 年 6 月 30 日
cellfun(@nnz, mycell)
  1 件のコメント
Levente Gellért
Levente Gellért 2021 年 6 月 30 日
Dear Walter Roberson, that's great, I did not know the function nnz, Thanks for your help. lg

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by