Find index of first nonempty cell in array?
29 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Tom
il 13 Giu 2013
Commentato: Peeyush Awasthi
il 1 Dic 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!
0 Commenti
Risposta accettata
Azzi Abdelmalek
il 13 Giu 2013
A = {['pizza'] ['pepperoni'] ['cheese'] [] []}
find(cellfun(@isempty,A),1)
2 Commenti
Jan
il 14 Giu 2013
As usual I mention, that cellfun('isempty', A) is faster.
You do not need square brackets around strings.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!