how can I delete empty elements of a cell?
Mostra commenti meno recenti
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?
Risposte (2)
Walter Roberson
il 12 Mar 2013
c( cellfun( @isempty, c ) ) = [];
2 Commenti
may
il 12 Mar 2013
Walter Roberson
il 12 Mar 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.
the cyclist
il 12 Mar 2013
c = c(not(cellfun(@isempty,c)))
Categorie
Scopri di più su Data Type Conversion in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!