Delete empty cells in array; keep column / row structure

2 ビュー (過去 30 日間)
Jamacker
Jamacker 2021 年 3 月 6 日
回答済み: Basil C. 2021 年 3 月 6 日
I have a 17x31 cell array (A) with empty cells. I need to delete all empty cells and reduce the array accordingly. I.e. in the example screenshot the output should be a 17x2 array.
With the following code I get a single column (34x1):
newA = A(~cellfun(@isempty, A));
Any ideas?

回答 (1 件)

Basil C.
Basil C. 2021 年 3 月 6 日
the function cellfun iterates through each cell in the cell array A.
Suppose if 31 elements where to remain rather than 34, then should the resultant cell matrix have the size of (1x31)??? or should it be (17x2) with last three elements empty??? to avoid such confusion the resultant is stored in the form of (n x 1)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by