how can I delete empty elements of a cell?

1 Ansicht (letzte 30 Tage)
may
may am 12 Mär. 2013
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?

Antworten (2)

Walter Roberson
Walter Roberson am 12 Mär. 2013
c( cellfun( @isempty, c ) ) = [];
  2 Kommentare
may
may am 12 Mär. 2013
is this the same as
result = c(~cellfun('isempty',c))
?
Walter Roberson
Walter Roberson am 12 Mär. 2013
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.

Melden Sie sich an, um zu kommentieren.


the cyclist
the cyclist am 12 Mär. 2013
c = c(not(cellfun(@isempty,c)))

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by