If we run the following code we will see that there is no space between 'is' and number '1'. I wonder how I can put a space in a text.
s=strcat('this is ',num2str(1),' my cat')

 채택된 답변

Paulo Silva
Paulo Silva 2011년 6월 12일

2 개 추천

s=['this is ' num2str(1) ' my cat']
strcat ignores trailing ASCII white space characters and omits all such characters from the output. White space characters in ASCII are space, newline, carriage return, tab, vertical tab, or form-feed characters, all of which return a true response from the MATLAB isspace function. Use the concatenation syntax [s1 s2 s3 ...] to preserve trailing spaces. strcat does not ignore inputs that are cell arrays of strings.

댓글 수: 2

Hassan
Hassan 2011년 6월 12일
thanks Paula for the help.
David Ebert
David Ebert 2022년 9월 29일
Helped me a lot, Paolo, thanks!

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

추가 답변 (0개)

카테고리

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

태그

질문:

2011년 6월 12일

댓글:

2022년 9월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by