How do I remove '1x1 cells' from a cell array?

19 ビュー (過去 30 日間)
Judith
Judith 2015 年 9 月 4 日
コメント済み: Judith 2015 年 9 月 4 日
I have a 203x1 cell array containing both 1x1 cells and 1x2 cells. For example:
1x1 cell 1x2 cell 1x2 cell 1x2 cell 1x1 cell 1x1 cell
From this cell array, I want to remove the 1x1 cell. How can I remove the 1x1 cells, or how do I keep only the 1x2 cells?
The 1x1 cells are preferably removed, but if they get blanco I will be able to remove them.
Thanks in advance, greetings, Judith

回答 (1 件)

James Tursa
James Tursa 2015 年 9 月 4 日
Try this (caution, untested):
cell_array = your cell array;
x = cellfun(@numel,cell_array);
cell_array(x==1) = [];
  1 件のコメント
Judith
Judith 2015 年 9 月 4 日
Thank you very much!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeData Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by