Find index of first nonempty cell in array?

24 views (last 30 days)
Hi,
I have a cell array with values and empty cells. I'd like to return the index of the first empty cell.
For example, for
A = [pizza] [pepperoni] [cheese] [] []
I'd like to return a value of 4.
Thanks!

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 13 Jun 2013
A = {['pizza'] ['pepperoni'] ['cheese'] [] []}
find(cellfun(@isempty,A),1)
  2 Comments
Jan
Jan on 14 Jun 2013
As usual I mention, that cellfun('isempty', A) is faster.
You do not need square brackets around strings.

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!