t=1:5; s1=sin(t); s2=cos(t); s=[t;s1;s2]; fid1=fopen('test.dat','wt'); fprintf(fid1,' This is a Formated file '); fprintf(fid1,' %4d %+12.5E %+12.5E ',s); fclose(fid1); fid2=fopen('test.dat','rt'); [A1,count1]=fscanf(fid2,'%s',5); [A2,count2]=fscanf(fid2,'%4d %e %e',[3,inf]); A2=A2'; fclose(fid2);
fid=fopen('d:data.txt','r') line=fgetl(fid) k=findstr(line,'cgg') s=length(k) line=fgetl(fid) k=findstr(line,'cgg') s=length(k) fclose(fid) ------- for k=0:99 p=int2str(k); fname=strcat('picture',p,'.bmp') %构成一有规律的文件名 打开图像fname 进行处理; 关闭当前图像文件; end