Writing text file

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일

0 개 추천

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일

0 개 추천

ahhhhhhh, i use the dlmwrite('D:\rrr.txt','delimiter','\t') instead.
Whichever works for the moment !! ;)

카테고리

도움말 센터File Exchange에서 Standard File Formats에 대해 자세히 알아보기

태그

질문:

2012년 1월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by