Writing text file

6 次查看(过去 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
ahhhhhhh, i use the dlmwrite('D:\rrr.txt','delimiter','\t') instead.
Whichever works for the moment !! ;)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by