how to count the number of empty cells in an array?

조회 수: 38 (최근 30일)
Sarah A
Sarah A 2020년 4월 20일
댓글: Stephen23 2020년 4월 21일
Hello,
How to count the empty cells in the attached array?
Regards,

채택된 답변

Muthu
Muthu 2020년 4월 20일
Hello Sarah,
You can count the empty cells using the following commands
N_nonempty = find(~cellfun(@isempty,Out));
count_empty = length(Out)-length(N_nonempty);
  댓글 수: 2
Sarah A
Sarah A 2020년 4월 20일
it works. Thank you :)
Stephen23
Stephen23 2020년 4월 21일
Much simpler and more efficient just to count the output of cellfun directly:
>> nnz(cellfun(@isempty,Out))
ans = 216

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by