这个程序的目的是,逐行读取file.txt文件中的字符串,并判断字符串中是否含有特定的字符,如果含有,再对字符串进行处理,然后写入到新的TXT文档中new_file.txt
fid=fopen('D:\new_file.txt','wt');
phns = 'D:\file.txt';
fpn = fopen (phns(1,:), 'rt'); %
while feof(fpn) ~= 1%
file = fgetl(fpn);
if ~isempty(strfind(file,'m'))
%如果字符串中含有“m”则执行if内的程序
end
fprintf(fid,'%s',file);
end
fclose(fid);
fclose(fpn);