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);

猜你喜欢

转载自www.cnblogs.com/hdawen/p/9184687.html