将矩阵按照原格式进行输出到txt [m,n]=size(coord1); for i=1:m for j=1:n if j==n fprintf(fid,'%f\n',coord1(i,j)); else fprintf(fid,'%f ',coord1(i,j)); end end end