MATLAB: Writing text file

txt

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

Best Answer

fid = fopen('exp.txt', 'w');
fprintf(fid, '%g\n', time);
fclose(fid);