フィルターのクリア

How to write characters into a new line in text file?

38 ビュー (過去 30 日間)
Minu
Minu 2013 年 6 月 5 日
Hi
I want to know how to write characters into a new line in text file.Please help me....
  1 件のコメント
Jan
Jan 2013 年 6 月 5 日
Is the file existing and/or open already?

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

回答 (2 件)

Jan
Jan 2013 年 6 月 5 日
Perhaps this helps:
fid = fopen(FileName, 'a');
fprintf(fid, '\nNew message in new line\n');
fclose(fid);
See also:
doc fopen
doc fwrite
doc fprintf

Iain
Iain 2013 年 6 月 5 日
fid = fopen(filename,writeaccess);
fseek(fid, ...)
fwrite(fid,['Hi' 13 10 'World'],'char');
...
fclose(fid)
Thats the code to open a text file, seek to a position in the file (needed if you are APPENDING), and writes "Hi", new line, "World", and then closes the file. That is the low-level way of doing it, there are dedicated text writing functions that may suit your need better.
  1 件のコメント
Jan
Jan 2013 年 6 月 5 日
While CHAR([13, 10]) are the old DOS line breaks, all modern software as Matlab's editor, Word, other editors handle CHAR(10) also. This works on many platforms today and only the Windows Editor cannot handle this correctly, such that I'd recommend to use either WordPad or NotePad++ as standard editor.

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

カテゴリ

Help Center および File ExchangeLow-Level File I/O についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by