필터 지우기
필터 지우기

Reading a binary data file

조회 수: 27 (최근 30일)
KatherineS
KatherineS 2019년 6월 7일
댓글: Walter Roberson 2019년 6월 8일
Hello,
I am trying to import and read a binary data file of the following format in MATLAB. I need to read in all the data, however at this point im just trying to read in the first 4 char, but i keep getting a blank array. Nothing seems to be working and I have been stuck for days.
Thanks in advance for your help!
fid = fopen('file.dat','r');
if fid <0
error('error opening file %s\n file.dat')
end
Program_label = fread(fid,[1 4],*char)
fclose(fid);
m = memmapfile('GSS1_t023_is_phcorr_ideal.dat');
m.Format

답변 (1개)

Jan
Jan 2019년 6월 7일
fid = fopen('file.dat','r');
if fid <0
error('error opening file %s\n file.dat')
end
Program_label = fread(fid, [1 4], '*char'); % With quotes
Program_version = fread(fid, 1, 'single');
Type_label = fread(fid, [1 4], '*char');
nCols = fread(fid, 1, 'uint32');
nRows = fread(fid, 1, 'uint32');
...
fclose(fid);
  댓글 수: 8
Walter Roberson
Walter Roberson 2019년 6월 8일
The file is empty.
Walter Roberson
Walter Roberson 2019년 6월 8일
dinfo = dir('file.dat')
and look at the bytes information. I think it will show 0

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

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by