Cell array to 1x1 Vector/Cell
显示 更早的评论
Hi
If I have a cell array such as c = {'word1','word2'}
How can I take this and convert it into a 1x1 cell that has all the words in the 1 cell but seperated by a space? Is this possible?
So say the 1x1 matrix would be: word1 word2
Thanks
edit: cell2mat doesnt give me the space in between. it does "word1word2"
1 个评论
Since R2016b:
c = {'word1','word2'}
join(c)
回答(2 个)
Oleg Komarov
2012-3-1
This is one way:
c2 = deblank(sprintf('%s ',c{:}));
类别
在 帮助中心 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!