'Merge' two cell arrays into one single cell array (NOT concatenation!)
2 次查看(过去 30 天)
显示 更早的评论
Dear All,
I am not familiar with cell array and have one simple question as follows-
There are two 1x2 cell arrays, for c1={1;2 5} , and c2= {3;4 6;7;8;9;10}.
Now I need to create a new 1x2 cell array c3 that = {1;2;3;4 5;6;7;8;9;10}.
I've tried concatenate but it returned as a 2x2 cell array
My code c3=cat(1,c1,c2)
Please let me know how to do this correctly, any advice would be appreciated!
K
0 个评论
采纳的回答
Stephen23
2021-8-8
c1 = {[1;2],5}
c2 = {[3;4],[6;7;8;9;10]}
out = cellfun(@vertcat,c1,c2,'uni',0)
celldisp(out)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!