how can I delete empty elements of a cell?
1 回表示 (過去 30 日間)
古いコメントを表示
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?
0 件のコメント
回答 (2 件)
Walter Roberson
2013 年 3 月 12 日
c( cellfun( @isempty, c ) ) = [];
2 件のコメント
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.
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!