Why \n or newline doesn't work ?

조회 수: 108 (최근 30일)
Lucas S
Lucas S 2021년 2월 17일
댓글: Lucas S 2021년 2월 17일
Hello !
I'm trying to concatenate a newline between 2 string and then put the entire string in the description of the block using :
Equation = strcat(Equation, sprintf("\n"), Equation2); %Or newline instead of sprintf("\n")
But it concatenate the 2 strings without the newline.
Do someone know why ?
Thanks for the help!

채택된 답변

Stephen23
Stephen23 2021년 2월 17일
"Do someone know why ?"
The documentation states "For character array inputs, strcat removes trailing ASCII white-space characters: space, tab, vertical tab, newline, carriage return, and form feed." It also suggests the workaround in the nest sentence: "For cell and string array inputs, strcat does not remove trailing white space."
strcat(Equation, {sprintf("\n")}, Equation2)
% ^ ^ scalar cell array
  댓글 수: 2
Walter Roberson
Walter Roberson 2021년 2월 17일
See also
strjoin({Equation, Equation2}, '\n')
Lucas S
Lucas S 2021년 2월 17일
Thanks !

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by