Why \n or newline doesn't work ?

104 ビュー (過去 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 Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by