1

可能重复:
如何在 MATLAB 中将数据保存在 .txt 文件中

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

4

2 回答 2

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

这应该可以解决问题。

于 2012-07-18T02:16:05.980 回答
0

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

fid1=fopen('file.txt','wt');
fprintf(fid1,'%8.6f\n',x(:,6));
fclose(fid1);
于 2012-07-18T11:14:49.263 回答