fprintfコマンドでテキストファイルに書き出したデータが改行されません。
55 views (last 30 days)
Show older comments
MathWorks Support Team
on 25 Oct 2013
Answered: MathWorks Support Team
on 25 Oct 2013
fprintfコマンドでテキストファイルに書き出したデータが改行されません。
Accepted Answer
MathWorks Support Team
on 25 Oct 2013
Windows環境では文字コードの関係で、テキストを改行するために、ニューライン(\n)だけでは改行されない場合があります。
対応方法として、次の2つの方法があります。
(1) fopen するときに、テキストモード('t')を指定してオープン
例:
fid = fopen('out.txt','wt');
fprintf(fid,'%i\n',3);
fclose(fid)
(2) fprintf で改行コードとして、ニューライン(\n)だけではなくキャレッジリターン(\r)も与え、'\r\n' と指定する
例:
fid=fopen('out.txt','w');
fprintf(fid,'%i\r\n',3);
fclose(fid)
0 Comments
More Answers (0)
See Also
Categories
Find more on 低水準ファイル I/O in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!