%识别文件中的这一行:' cell 2 ' :
func('o100.txt','reco400.txt','cell 2');
function linenum=func(filein,fileout,line)
fidin=fopen(filein, 'r');
fidout=fopen(fileout, 'w');
nline= 0;
while ~feof(fidin) % 判断是否为文件末尾
tline = fgetl(fidin); % 从文件读行
nline = nline + 1;
if contains(tline, line)
fprintf(fidout, '%s\n',num2str(nline));
fprintf(fidout, '%s\n',tline);
linenum = nline; %行数作为输出
end
end
fclose(fidin);
fclose(fidout);
end
특정 문자열을 포함하는 파일의 행 식별
추천
출처blog.csdn.net/weixin_40653652/article/details/115209987
추천
행