Filling cells with repetitive strings
39 次查看(过去 30 天)
显示 更早的评论
Hi
I want to create a 1x60 cell array (60 different elements). The elements 1:10 each should contain a certain string, say 'hello', then 11:20 should contain say 'tree' etc. How do I do this effectively? Currently I am using different loops for each string, but that seems not to be very effective..thanks
0 个评论
回答(3 个)
Walter Roberson
2017-1-24
https://www.mathworks.com/help/matlab/ref/repelem.html
Works on cells too.
Jan
2017-1-24
Strings = {'hello', 'tree', 'third', 'fifth', 'sixth'};
C = reshape(repmat(Strings, 10, 1), 1, []);
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!