MATLAB Answers

Finding/counting logical ones in a cell array

조회 수: 6(최근 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