merge multiply cell together

3 次查看(过去 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!

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2013-8-30
编辑:Azzi Abdelmalek 2013-8-30
C3=horzcat(C1,C2);
C3(cellfun('isempty',C3))=[]
  1 个评论
Jan
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 CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by