concatenating array using cellstr and repmat
1 次查看(过去 30 天)
显示 更早的评论
Hi All,
I have the following code
str = cellstr(char('This','Orthis'));
x = round(rand(10,1))+1;
output = [repmat('some text ',10,1) str{x}]
I want the output to look like:
output =
some text OrThis
some text This
some text This
etc..
where the last word in each row is selected by str{x}. This is not working, as the str{x} part of the concatenation is not generating the appropriate array. Any suggestions? Thanks!
0 个评论
采纳的回答
Azzi Abdelmalek
2013-5-2
str = cellstr(char('This','Orthis'))
x = round(rand(10,1))+1
output = [repmat('some text ',10,1) char(str(x))]
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Cell Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!