Writing text file
3 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Walter Roberson
2012-1-13
fid = fopen('exp.txt', 'w');
fprintf(fid, '%g\n', time);
fclose(fid);
2 个评论
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
2012-1-17
ahhhhhhh, i use the dlmwrite('D:\rrr.txt','delimiter','\t') instead.
Whichever works for the moment !! ;)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!