how can I delete empty elements of a cell?

suppose I have a cell c
c =
[]
[1x3 double]
[]
[]
[1x2 double]
and I want to delete all the empty elements in c and get
c =
[1x3 double]
[1x2 double]
how can I do this?

답변 (2개)

Walter Roberson
Walter Roberson 2013년 3월 12일

2 개 추천

c( cellfun( @isempty, c ) ) = [];

댓글 수: 2

is this the same as
result = c(~cellfun('isempty',c))
?
Walter Roberson
Walter Roberson 2013년 3월 12일
The form you gave will select the non-empty entries into "result" leaving everything in "c". The form I gave will delete the empty entries in "c" leaving "c" with no empty entries. Based on your showing "c =" in your question, what I gave is what you requested.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

제품

질문:

may
2013년 3월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by