MATLAB: Question answered, thanks: question on line break using fprintf

fprintflinebreak

Hi
I need to write several lines of text to the user. I am using fprintf, but even though I write the text on consecutive lines, using fprintf each time, it all gets put together to one long string when I execute the program. Could someone please tell me how I get line breaks in the text?
Thanks a bunch!

Best Answer

Include the ‘newline’ ('\n') character at the end of each line:
fprintf('This is the first line\n')
fprintf('This is the second line with two newline characters to provide a blank line\n\n')
fprintf('This is the third line\n')
See the documentation for fprintf, specifically Text Before or After Formatting Operators, for details.