Matlab将数据输出到txt

    clear all;
    Totalnum=input('Please input the total number of .sdf files,end with 'Enter':');
    fid=fopen('maxEx_out.txt','wt');
    for i=1:Totalnum
      if i<=9
          q=GetDataSDF(['000',num2str(i),'.sdf']);
      elseif i<=99
          q=GetDataSDF(['00',num2str(i),'.sdf']);
      else
          q=GetDataSDF(['0',num2str(i),'.sdf']);
      end
        %q=GetDataSDF('0260.sdf');
          ex = q.Electric_Field.Ex.data;
          ex = ex';
          ex = ex/(1e9);
          ex0 = ex(300,:);
          Emax = min(ex0);
          fprintf(fid,'%8.6f\r\n',Emax);

    end

    fclose(fid);

输出在txt中为列格式,在个人电脑上,,

fprintf(fid,'%8.6f\n',Emax);

在服务器上为

fprintf(fid,'%8.6f\r\n',Emax);

Matlab将数据输出到txt_第1张图片

你可能感兴趣的:(Matlab)