a =[17 24 1 8 15;23 5 7 14 16 ;4 6 13 20 22 ;10 12 19 21 3 ;11 18 25 2 9 ];
fid=fopen('tt.txt','w');%写入文件路径
[m,n]=size(a);
for i=1:1:m
for j=1:1:n
if j==n
fprintf(fid,'%g\n',a(i,j));
else
fprintf(fid,'%g\t',a(i,j));
end
end
end
fclose(fid);
来源:CSDN
作者:方便面袋袋
链接:https://blog.csdn.net/qq_43807789/article/details/103473855