Concatenate cell arrays element-wise
9 次查看(过去 30 天)
显示 更早的评论
Hi, I have two cell arrays: A = {'a','b'}, and C = {'c','d'}.
How can I write a loop to take each element of A and concatenated it with each element of C?
Result = {'ac','ad','bc','bd'}
Any help would be appreciated! Thanks,
Sushma
0 个评论
采纳的回答
Andrei Bobrov
2015-3-22
编辑:Andrei Bobrov
2015-3-22
out = strcat(A(kron(1:2,[1,1])),C(kron([1,1],1:2)));
or
[y,x]=ndgrid(1:2);
out = strcat(A(x(:)),C(y(:)));
0 个评论
更多回答(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!