Writing text file

5 ビュー (過去 30 日間)
Andy
Andy 2012 年 1 月 13 日
If i have a variable, say time=1000, and i want to write this into a txt file, how do i do that?
this is what i have tried:
fid = fopen('exp.txt', 'w');
fprintf(fid, 'time');
fclose(fid);
thanks

採用された回答

Walter Roberson
Walter Roberson 2012 年 1 月 13 日
fid = fopen('exp.txt', 'w');
fprintf(fid, '%g\n', time);
fclose(fid);
  2 件のコメント
Andy
Andy 2012 年 1 月 16 日
hi, thanks for the response, but i tried it, it doesnt save anything.
Walter Roberson
Walter Roberson 2012 年 1 月 16 日
Works fine for me.
>> time = 1000
time =
1000
>> fid = fopen('exp.txt', 'w');
fprintf(fid, '%g\n', time);
fclose(fid);
>> !cat exp.txt
1000

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

その他の回答 (1 件)

sunil anandatheertha
sunil anandatheertha 2012 年 1 月 17 日
ahhhhhhh, i use the dlmwrite('D:\rrr.txt','delimiter','\t') instead.
Whichever works for the moment !! ;)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by