将矩阵输出到txt文件中的方法,遍寻网络,始见真经!!!
fid=fopen(\'C:Documents and Settingscleantotal.ped\',\'wt\');%写入文件路径
matrix=input_mattrix %input_matrix为待输出矩阵
[m,n]=size(matrix);
for i=1:1:m
for j=1:1:n
if j==n
fprintf(fid,\'%g\n\',matrix(i,j));
else
fprintf(fid,\'%g\t\',matrix(i,j));
end
end
end
fclose(fid);
[m,n]=size(matrix);
for i=1:1:m
for j=1:1:n
if j==n
fprintf(fid,\'%g\n\',matrix(i,j));
else
fprintf(fid,\'%g\t\',matrix(i,j));
end
end
end
fclose(fid);