Find index of first nonempty cell in array?

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!

 Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 13 de Jun. de 2013
A = {['pizza'] ['pepperoni'] ['cheese'] [] []}
find(cellfun(@isempty,A),1)

2 comentarios

Jan
Jan el 14 de Jun. de 2013
As usual I mention, that cellfun('isempty', A) is faster.
You do not need square brackets around strings.
Peeyush Awasthi
Peeyush Awasthi el 1 de Dic. de 2020
Perfect answer by Jan.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Preguntada:

Tom
el 13 de Jun. de 2013

Comentada:

el 1 de Dic. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by