I used fread function read binary data file but returned all zero after 999 column, how to solve this problem?
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
Jan
2022-10-29
编辑:Jan
2022-10-29
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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File 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!