Why \n or newline doesn't work ?

87 Ansichten (letzte 30 Tage)
Lucas S
Lucas S am 17 Feb. 2021
Kommentiert: Lucas S am 17 Feb. 2021
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!

Akzeptierte Antwort

Stephen23
Stephen23 am 17 Feb. 2021
"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 Kommentare
Walter Roberson
Walter Roberson am 17 Feb. 2021
See also
strjoin({Equation, Equation2}, '\n')
Lucas S
Lucas S am 17 Feb. 2021
Thanks !

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by