merge multiply cell together
1 回表示 (過去 30 日間)
古いコメントを表示
Hi guys: I have two cells as follow:
C1={[1:10], [2; 4; 6], []};
C2={[],[],[2;3];
These two cell has same length and opposite void and valid elements, I want to put the elements in one cell , let's say C3={[1:10], [2; 4; 6],2;3]} How can I do that? Thank you very much!
0 件のコメント
採用された回答
Azzi Abdelmalek
2013 年 8 月 30 日
編集済み: Azzi Abdelmalek
2013 年 8 月 30 日
C3=horzcat(C1,C2);
C3(cellfun('isempty',C3))=[]
1 件のコメント
Jan
2013 年 8 月 30 日
Equivalent, but perhaps slightly faster for huge cells:
index = cellfun('isempty', C1);
C3 = cat(2, C1(~index), C2(index));
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!