Printing an embedded newline character in a string using fprintf
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a string that I would like to print using fprintf, but I want to embed a newline character in the string as part of the argument. Here is the output to the below code:
mystring =
"This is my string.\nIt is too long so I use newline\ncharacters to print on the next line."
This is my string.\nIt is too long so I use newline\ncharacters to print on the next line.
mystring = "This is my string.\nIt is too long so I use newline\ncharacters to print on the next line.";
fprintf('%s',mystring);
0 comentarios
Respuestas (1)
Jan
el 21 de Sept. de 2021
Editada: Jan
el 21 de Sept. de 2021
mystring = "This is my string.\nIt is too long so I use newline\ncharacters to print on the next line.";
fprintf(mystring);
Or:
mystring = "This is my string.\nIt is too long so I use newline\ncharacters to print on the next line.";
str = sprintf(mystring);
fprintf('%s', str)
0 comentarios
Ver también
Categorías
Más información sobre String Parsing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!