Borrar filtros
Borrar filtros

fwrite and fread data of multiple precision to binary file

4 visualizaciones (últimos 30 días)
Jab
Jab el 2 de Abr. de 2018
Comentada: Jab el 2 de Abr. de 2018
Can anyone help me? fwrite and fread values are different. My trail is given below. i need to only read the sq values.
Thanks
r=1:100;
sq= sqrt(r)
fid = fopen('binary','w'); % Opening the file to write
%
if fid~=1
fwrite(fid, 8, 'uint8');
fwrite(fid, 'Table', 'char');
fwrite(fid, sq, 'float64');
fclose(fid);
end
fileid = fopen('binary','r');
if fileid~=1
equa = fread(fileid, 'float64');
fclose(fileid);
end

Respuesta aceptada

Walter Roberson
Walter Roberson el 2 de Abr. de 2018
You need to fseek() to skip the first 6 bytes of the file.
  3 comentarios
Walter Roberson
Walter Roberson el 2 de Abr. de 2018
That is fine. fseek returns 0 if the operation succeeded.
Jab
Jab el 2 de Abr. de 2018
Thank you! Get the job done

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Low-Level File I/O en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by