Matlab文本处理:提取指定内容

clc;clear;
fileno=1;
for i=1:fileno
    fid2=fopen('4B1T_wb_eq.txt','w'); %save data to 'logfile' in Matlab current working directory
    fid=fopen('4B1T_wb_eq.log','r'); %read NAMD log file fid=fopen([loadpath groupdir(i).name],'r');
    while(~feof(fid))
        newl=fgetl(fid);
        if ~isempty(strfind(newl,'ENERGY:'))
              fprintf(fid2,'%s\n',newl);   % 提取的是字符串
%             if (~isempty(strfind(newl(13:15),' 30')))
%                 fprintf(fid2,'%s\n',newl(16:48));
%             end
        end        
    end
    fclose(fid);
end
fclose(fid2);
  • 本文作者: Hdawen
  • 出处:原文链接
  • 版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明出处!
原文地址:https://www.cnblogs.com/hdawen/p/9184687.html