A={[3,4],[8,9],[1,2],0,0,0};
A(cell2mat(A)==0)={[]};
I used this code, but have error
Error using cat
Dimensions of arrays being concatenated are not consistent.
Error in cell2mat (line 2)
m{n} = cat(2,c{n,:});
Result should be
A={[3,4],[8,9],[1,2],[],[],[]};

 採用された回答

Andrei Bobrov
Andrei Bobrov 2019 年 6 月 28 日

0 投票

A(cellfun(@(x)numel(x) == 1 && x == 0,A)) = {[]};

その他の回答 (1 件)

カテゴリ

ヘルプ センター および File ExchangeCell Arrays についてさらに検索

質問済み:

NA
2019 年 6 月 28 日

回答済み:

2019 年 6 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by