Can I use the Import Wizard to open files that are partially in ASCII format and partly in binary format?

2 次查看(过去 30 天)
I have a data file with header lines that are in ASCII format and the data in binary format. I would like to use the Import Wizard to open such files and appropriately retrieve the binary formatted data.

采纳的回答

MathWorks Support Team
编辑:MathWorks Support Team 2021-10-21
The ability to interpret data files that are partly in ASCII format and partly in binary format is not available with the MATLAB Import Wizard. To work around this issue, use the MATLAB file I/O functions to read and interpret such data files. For a complete list of file I/O functions in MATLAB, please refer to the following documentation page:
The following example code reads a file that has a few header lines in ASCII format using the FGETL function and then reads the subsequent binary formatted data using the FREAD function.
function [hdr,data] = myBinaryReader(filename,headerlines)
hdr = [];
fid = fopen(filename,'r');
for(i=1:1:headerlines)
hdr{i} = fgetl(fid);
end
data = fread(fid);
fclose(fid)

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by