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
sunil anandatheertha 2012년 1월 17일
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