Create string of dots characters

2 次查看(过去 30 天)
Hi,
I want to create a string of dots character like the function blanks does to create spaces. how do I do that?

采纳的回答

Simon
Simon 2014-1-7
Use repmat:
repmat('.', 1, 10)

更多回答(1 个)

David Sanchez
David Sanchez 2014-1-7
function my_dots(n)
str = '';
for k=1:n
str = strcat(str,'.');
end
disp(str)
>> my_dots(3)
...
>> my_dots(10)
..........
  1 个评论
Jos (10584)
Jos (10584) 2014-1-7
In every iteration, str grows by one element, making this painstakingly slow with increasing n … MLint warns you for this problem.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Numeric Types 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by