Effacer les filtres
Effacer les filtres

Find index of first nonempty cell in array?

29 vues (au cours des 30 derniers jours)
Tom
Tom le 13 Juin 2013
Commenté : Peeyush Awasthi le 1 Déc 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!

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by