【发布时间】:2017-06-11 15:56:32
【问题描述】:
有 4 个 numpy 矩阵,例如,3x3 坐标:
Xg [[-0.5 0.3 1.1]
[-0.5 0.3 1.1]
[-0.5 0.3 1.1]]
Yg [[-0.5 -0.5 -0.5]
[ 0.3 0.3 0.3]
[ 1.1 1.1 1.1]]
u [[ 1. 1. 1.]
[ 1. 1. 1.]
[ 1. 1. 1.]]
v [[ 1.03793 0.25065 -0.28944]
[-0.21591 -0.93072 -0.10047]
[-0.08591 -0.11284 -0.06082]]
如何在文件中写入坐标:
# in file should be ", {{" x_coordinate","y_coordinate"},{"u_coordinate","v_coordinate"}}")
file = open("coordinates.txt", "w")
file.write(",{{" + x + "," + y + "},{" + u + "," + v + "}}")
#Output
,{{-0.5,-0.5},{1,1.03793}}, {{0.3,-0.5},{1,0.25065}}, {{1.1,-0.5},{1,-0.28944}},...
【问题讨论】:
-
“下一步”是什么意思?
-
numpy.savetxt不符合您的要求吗? docs.scipy.org/doc/numpy/reference/generated/numpy.savetxt.html -
我的英语不太好,当说“下一条路”时,我的意思是“像这样”