我有一个由数字 1 到 9 组成的.dat文件,如下所示:
1
阿拉伯数字
3
四
5
6
7
8
9
如何将数据导入 mathematica,使其具有 {{1,2,3},{4,5,6},{7,8,9}} 的形式,并且可以生成我的 3x3 矩阵?
我建议:
data=Partition[Import["<Name of data file>", "Table"],3];
ReadList["file.dat", {Number, Number, Number}]
{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}
也可以写成:
ReadList["file.dat", Number ~Table~ {3}]