How to remove empty cells from array

Hi,
I'm very new to matlab :)
How can I remove the empty cells from the array in the attached image?
I have tried data(~cellfun('isempty',data)), but this didn't work.
Thank you for the help.

4 件のコメント

Stephen23
Stephen23 2021 年 8 月 23 日
@Daneisha Blair: currently you have a 151x11 cell array.
What shape/size do you expect to get once all of the empty cells are removed?
Daneisha Blair
Daneisha Blair 2021 年 8 月 23 日
I'm looking for a shape with 1 column and the row equals to the amount of non-empty cells. Example m by 1. Let me know if my explanationhelps?
Daneisha Blair
Daneisha Blair 2021 年 8 月 23 日
I figure it out :), data(cellfun(@isempty,data))=[]; works.
Thanks!
Stephen23
Stephen23 2021 年 8 月 23 日
@Daneisha Blair: yes,
data(cellfun(@isempty,data))=[];
is probably the best way to do this.

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

回答 (1 件)

KSSV
KSSV 2021 年 8 月 23 日

3 投票

If C is your cell array, you can remove the empty cells using:
C = C(~cellfun('isempty',C)) ;

カテゴリ

ヘルプ センター および File ExchangeSurfaces, Volumes, and Polygons についてさらに検索

質問済み:

2021 年 8 月 23 日

コメント済み:

2021 年 8 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by