读取指定路径 .txt 十六进制文件

filepath = 'C:\Desktop\2023-04-11-10-21-42_1.txt';
fid = fopen(filepath, 'r');
data = '1';
N = 0;
while( 0 == strcmp('', data) )
  data = fscanf(fid, '%s', 1);
  if ( 0 == strcmp('', data) )
    N = N + 1;
  end
end
dataVec = zeros(N, 1);
fseek(fid, 0, 'bof');
for i = 1:1:N
  data = fscanf(fid, '%s', 1);
  dotBuff = hex2dec(data);
  dataVec(i) = dotBuff;
end

 

posted @ 2023-04-24 14:19  SusieSnail_SUN  阅读(23)  评论(0编辑  收藏  举报