MATLAB Answers

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

49 views (last 30 days)
Sarah A
Sarah A on 20 Apr 2020
Commented: Stephen Cobeldick on 21 Apr 2020
How to count the empty cells in the attached array?


Sign in to comment.

Accepted Answer

Muthu on 20 Apr 2020
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);


Stephen Cobeldick
Stephen Cobeldick on 21 Apr 2020
Much simpler and more efficient just to count the output of cellfun directly:
>> nnz(cellfun(@isempty,Out))
ans = 216

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!