将矢量保存在txt文件中

时间:2012-07-18 01:59:44

标签: matlab

  

可能重复:
  How to save data in .txt file in MATLAB

我有Matlab这个问题。我有一个矩阵x,例如x(100,10)。我想在txt文件中仅保存第六列,但是当我用记事本打开txt文件时,我希望在列中看到数字。 希望可以有人帮帮我。 提前谢谢。

2 个答案:

答案 0 :(得分:1)

x = randi(100, 100, 10);
y = x(:, 6);
save('sixthcol.txt', 'y', '-ascii');

这应该可以解决问题。

答案 1 :(得分:0)

谢谢安萨里。实际上我的一位朋友向我建议了这些命令并且效果很好:

fid1=fopen('file.txt','wt');
fprintf(fid1,'%8.6f\n',x(:,6));
fclose(fid1);
相关问题