Printing an embedded newline character in a string using fprintf
조회 수: 19 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Jan
2021년 9월 21일
편집: Jan
2021년 9월 21일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!