下面两段程序是批量存储和批量读取二进制dat文件:
for j=1:20
for i=1:4
filename=strcat('d',num2str(j),'c',num2str(i),'.dat');
fid=fopen(filename,'wb');
fwrite(fid,angle(roughsensitivity(:,:,j,i)),'float');
fclose(fid);
end
end
for j=1:20
for i=1:4
filename=strcat('und',num2str(j),'c',num2str(i),'.dat');
fid=fopen(filename,'rb');un=fread(fid,'float');fclose(fid);
un=reshape(un,256,256);
phase(:,:,j,i)=un;
end
end