clc; clear all; fid=fopen('sy.txt','r+'); if(fid==-1) display('File not exist!'); return; end while(~feof(fid)) g=fgets(fid); a=str2num(g); if a>2000&&a<4000 e=fopen('new3.txt','a+'); fprintf(e,'%5.7g\r\n',a); fclose(e); end end fclose(fid);