Finding/counting logical ones in a cell array

6 vues (au cours des 30 derniers jours)
Levente Gellért
Levente Gellért le 30 Juin 2021
Commenté : Levente Gellért le 30 Juin 2021
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

Réponse acceptée

Walter Roberson
Walter Roberson le 30 Juin 2021
cellfun(@nnz, mycell)
  1 commentaire
Levente Gellért
Levente Gellért le 30 Juin 2021
Dear Walter Roberson, that's great, I did not know the function nnz, Thanks for your help. lg

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Operators and Elementary Operations dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by