Convert Cell to String
6 次查看(过去 30 天)
显示 更早的评论
I have a cell array:
x = {'red' 'blue' 'green'}
I need to convert it to a string (looking for another way besides char). So the output would be:
red
blue
green
Thanks, Amanda
1 个评论
Walter Roberson
2013-5-2
A single string with something (like a newline) between the parts? Or one string per cell entry? Is this for storing or for displaying? Could you indicate why using "char" is not desirable ?
采纳的回答
Cedric
2013-5-2
You could use something like:
s = sprintf('%s\n', x{:})
3 个评论
Walter Roberson
2013-5-2
Note that this would have newline characters between the parts. I am not sure that is what the poster wants.
更多回答(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!