Find index of first nonempty cell in array?

29 次查看(过去 30 天)
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!

采纳的回答

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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by