Writing text file

6 visualizaciones (últimos 30 días)
Andy
Andy el 13 de En. de 2012
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

Respuesta aceptada

Walter Roberson
Walter Roberson el 13 de En. de 2012
fid = fopen('exp.txt', 'w');
fprintf(fid, '%g\n', time);
fclose(fid);
  2 comentarios
Andy
Andy el 16 de En. de 2012
hi, thanks for the response, but i tried it, it doesnt save anything.
Walter Roberson
Walter Roberson el 16 de En. de 2012
Works fine for me.
>> time = 1000
time =
1000
>> fid = fopen('exp.txt', 'w');
fprintf(fid, '%g\n', time);
fclose(fid);
>> !cat exp.txt
1000

Iniciar sesión para comentar.

Más respuestas (1)

sunil anandatheertha
sunil anandatheertha el 17 de En. de 2012
ahhhhhhh, i use the dlmwrite('D:\rrr.txt','delimiter','\t') instead.
Whichever works for the moment !! ;)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by