Combine two cell arrays containing string values into one.
10 次查看(过去 30 天)
显示 更早的评论
Hi.
I have two cell arrays that look something like this:
A = {'1.'; '2.'; '3.'; '4.', '5.'};
B = {'A'; 'B'; 'C'; 'D'; 'E'};
Both are of the same length.
I want to combine them into a third cell array that looks like this:
C = {'1. A'; '2. B'; '3. C'; '4. D'; '5. E'};
How can I do this?
Thanks!
0 个评论
采纳的回答
Azzi Abdelmalek
2013-9-25
编辑:Azzi Abdelmalek
2013-9-25
A = {'1.'; '2.'; '3.'; '4.'; '5.'};
B = {'A'; 'B'; 'C'; 'D'; 'E'};
C=cellfun(@(x,y) [x ' ' y],A,B,'un',0)
3 个评论
Johannes Rebling
2020-4-7
For those like me, wondering what the 'un',0 at the end of cellfun means, it's the same as 'UniformOutput',true. Thanks for the solution!
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!