fwrite and fread data of multiple precision to binary file

조회 수: 9 (최근 30일)
Jab
Jab 2018년 4월 2일
댓글: Jab 2018년 4월 2일
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

채택된 답변

Walter Roberson
Walter Roberson 2018년 4월 2일
You need to fseek() to skip the first 6 bytes of the file.
  댓글 수: 3
Walter Roberson
Walter Roberson 2018년 4월 2일
That is fine. fseek returns 0 if the operation succeeded.
Jab
Jab 2018년 4월 2일
Thank you! Get the job done

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by