MATLAB: What is the syntax of fprintf

fprint function

In this example for writing to a file I understand each part except why the first line has 2 "n"s and the second line has an n'?
fprintf(nout,'No of iterations = %5d\n\n,niter);
fprintf(nout,Estimate of root = %12.4e\n', xf);

Best Answer

Why not read the documentation?
And part way down the page is a table of "Special characters that you cannot enter as ordinary text. This table shows how to represent special characters in formatSpec." Scan down the table and we find \n:
Special Character Representation
Single quotation mark ''
Percent character %%
Backslash \\
...
New line \n
...
So whoever wrote that code specified two newline characters in one location, and just one newline in another location. The effect of two adjacent newline characters is to create an empty line. You would have to ask the code author why they wanted that.