フィルターのクリア

Find index of first nonempty cell in array?

29 ビュー (過去 30 日間)
Tom
Tom 2013 年 6 月 13 日
コメント済み: Peeyush Awasthi 2020 年 12 月 1 日
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.
Peeyush Awasthi
Peeyush Awasthi 2020 年 12 月 1 日
Perfect answer by Jan.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by