I need to create a new cell array using values from another, but excluding the empty values for example... [] 2 [] 1 I would like to have a new a cell array that only includes the 2 and the 1 and skip the empty values. so the final would just read...2 1

 採用された回答

Star Strider
Star Strider 2016 年 4 月 22 日

0 投票

This works:
Cell_1 = {[], 2, [], 1};
Cell_2 = Cell_1(cellfun(@(x) ~isempty(x), Cell_1))

その他の回答 (1 件)

John D'Errico
John D'Errico 2016 年 4 月 22 日

0 投票

Use cellfun with isempty to identify those cells that are empty. Then just delete those elements like you would delete elements of any other array.

1 件のコメント

Neal  Ousley
Neal Ousley 2016 年 4 月 22 日
Could you show an example?

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

カテゴリ

ヘルプ センター および File Exchange で Structures についてさらに検索

質問済み:

2016 年 4 月 22 日

回答済み:

2016 年 4 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by