필터 지우기
필터 지우기

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 CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by