matlab将矩阵按行和列存储到txt中

c为待存储的矩阵,将c按行和列存储到saif.txt中。

row=size(c,1);
col=size(c,2);
fid=fopen(['saif.txt'],'wt');
for i=1:row
for j=1:col
fprintf(fid,'%g ',c(i,j));
end
fprintf(fid,'\n');
end
fclose(fid);


 

猜你喜欢

转载自blog.csdn.net/qq_36480087/article/details/84785861