Clear Filters
Clear Filters

I used fread function read binary data file but returned all zero after 999 column, how to solve this problem?

1 view (last 30 days)
I had a binary data file and i used fread function to read it. The frame_length was 12000. The result of the part less than 998 can be normally displayed, but the columns larger than 999 were incorrectly displayed as 0. And the error message at the bild1024 row showed that the size of left part is 1024*1, right part is 0*0. What is wrong with this and how can I solve this problem? Please help me!
bild1024=zeros(1024,frame_length);
fid=fopen(fullname_get,'rb');
for i=1:frame_length
time_stamp=fread(fid, [1 2],'float32'); %read time stamp
dummy=fread(fid, [1],'float32'); %read dummy
time=fread(fid,[12000,1],'float32');
bild1024(:,i)=fread(fid, [1 1024],'float32');%read pixel values for each frame
int_value=fread(fid, [1 2],'int32'); %read MinMax, Event Marker,
EventText=fread(fid,[1 30],'int8'); % event marker
int_Time=fread(fid, [1 ],'int32'); %Timing Error
Medibus=fread(fid, [1 52],'float32'); % data from medibus
end
  1 Comment
Jan
Jan on 29 Oct 2022
Edited: Jan on 29 Oct 2022
Please post a copy of the error message instead of paraphrasing it.
What do you call "The result of the part less than 998"? How can you "normally display" it, if the code stops with an error?
"the columns larger than 999 were incorrectly displayed as 0" - of which variable?
Does "right part is 0*0" mean, that fread(fid, [1 1024],'float32') does not reply a value?
Do you really have 12'000 time values for 1024 pixel values in each frame?
You are overwriting all variables but build1024. Is this intented?
It might be useful, if you mention, which binary format you want to import.

Sign in to comment.

Answers (0)

Categories

Find more on Data Import and Export in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!