Can I use the Import Wizard to open files that are partially in ASCII format and partly in binary format?
1 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2009-6-27
编辑: MathWorks Support Team
2021-10-21
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
2021-10-21
编辑: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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Analysis 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!