matlab中如何将多个矩阵保存到同一个文本文件中?

2024-11-01 19:22:19
推荐回答(2个)
回答1:

function myWriteToTxt(A,address)
%待保存数据:A
%保存文件:address
fid=fopen(address,'a');
[r,v]=size(A);
for i=1:r
for j=1:v
fprintf(fid,'%d\t',A(i,j));
end
fprintf(fid,'\n ');
end
fprintf(fid,'\n ');
fclose(fid);

A=ones(17,17);
B=2*A;
C=3*A;
myWriteToTxt(A,address);
myWriteToTxt(B,address);
myWriteToTxt(C,address);

回答2:

用dlmread 和-append如何将多个矩阵保存到同一个文本文件?万分感谢!