Find index of first nonempty cell in array?

16 Ansichten (letzte 30 Tage)
Tom
Tom am 13 Jun. 2013
Kommentiert: Peeyush Awasthi am 1 Dez. 2020
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!

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 13 Jun. 2013
A = {['pizza'] ['pepperoni'] ['cheese'] [] []}
find(cellfun(@isempty,A),1)
  2 Kommentare
Jan
Jan am 14 Jun. 2013
As usual I mention, that cellfun('isempty', A) is faster.
You do not need square brackets around strings.
Peeyush Awasthi
Peeyush Awasthi am 1 Dez. 2020
Perfect answer by Jan.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Types finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by