我正在阅读二进制EDF文件,我必须在特定点将其拆分为多个较小的EDF文件,然后调整其中的一些值。总的来说它工作得很好,但是当我在文件中读到它时,它将2个字符数组相互组合。显然,所有后续词语也会被破坏。我走到了尽头,不知道自己做错了什么。
代码(写作)中必须包含问题的部分:
byt=fread(fid,8,'*char');
fwrite(tfid,byt,'*char');
fwrite(tfid,fread(fid,44));
%new number of records
s = records;
fwrite(tfid,s,'*char');
fseek(fid,8,0);
%test
fwrite(tfid,fread(fid,8,'*char'),'*char');
当我使用阅读器时,它结合了记录(fwrite(tfid,s,'*char')
)
使用下一个变量的值。之前的所有变量都会正确显示。读者的相关代码:
hdr.bytes = str2double(fread(fid,8,'*char')');
reserved = fread(fid,44);%#ok
hdr.records = str2double(fread(fid,8,'*char')');
if hdr.records == -1
beep
disp('There appears to be a problem with this file; it returns an out-of-spec value of -1 for ''numberOfRecords.''')
disp('Attempting to read the file with ''edfReadUntilDone'' instead....');
[hdr, record] = edfreadUntilDone(fname, varargin);
return
end
hdr.duration = str2double(fread(fid,8,'*char')');