Regarding "fwrite" in matlab

5 visualizaciones (últimos 30 días)
Aparna
Aparna el 19 de Mzo. de 2012
The following lines are a part of my code.
fid=fopen('M1.txt','w');
fwrite(fid,k,'int16');
fclose(fid);
I would like know how to include a delimiter. I need the .txt file to have 16 bits per line since this data has to be read line by line for further processing.
Kindly help me with this at the earliest.
Thank you

Respuesta aceptada

Titus Edelhofer
Titus Edelhofer el 22 de Mzo. de 2012
O.K., I give it another try:
x = 42;
fprintf(fid, '%s\n', dec2bin(x, 16));
Is that what you need?
Titus

Más respuestas (1)

Titus Edelhofer
Titus Edelhofer el 19 de Mzo. de 2012
Hi Aparna,
are you sure you want to use fwrite? With fwrite you write binary data (open your M1.txt with an editor that can display HEX data). There is no "line" in a text file usually. Could it be that you want to use fprintf instead?
If this is not the case, you could just use fprintf for the delimiter, i.e., add
fprintf(fid, '\n');
Hope this helps,
Titus
  8 comentarios
Asadullah
Asadullah el 1 de Oct. de 2012
Editada: Walter Roberson el 1 de Oct. de 2012
Walter Roberson
Walter Roberson el 1 de Oct. de 2012
That link leads to this question.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by