フィルターのクリア

What is the syntax of fprintf

1 回表示 (過去 30 日間)
Cian O'Regan
Cian O'Regan 2015 年 11 月 30 日
編集済み: Stephen23 2015 年 11 月 30 日
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);
  2 件のコメント
Stephen23
Stephen23 2015 年 11 月 30 日
編集済み: Stephen23 2015 年 11 月 30 日
Presumably your quoted string \u\n should actually be \n\n, which then matches your question. The escape code \u is not standard for any ASCII character.
Cian O'Regan
Cian O'Regan 2015 年 11 月 30 日
Apologies for the typo, I have corrected it thank you. It is the 2 n's in the first line compared with one n in the second line that I don't understand.

サインインしてコメントする。

採用された回答

Stephen23
Stephen23 2015 年 11 月 30 日
編集済み: Stephen23 2015 年 11 月 30 日
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.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by