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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM