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일

1 개 추천

Use repmat:
repmat('.', 1, 10)

추가 답변 (1개)

David Sanchez
David Sanchez 2014년 1월 7일

0 개 추천

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.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

질문:

ELI
2014년 1월 7일

댓글:

2014년 1월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by