如何将所有数组存储在 for 循环输出中

How to store all arrays in a for loop output

当我做这个 for 循环时,我只从代码中打印出一个数组

 npoints=10

x0 = np.zeros(npoints)
y0 = np.zeros(npoints)
z0 = np.zeros(npoints)
vx0 = np.zeros(npoints)
vy0 = np.zeros(npoints)
vz0 = np.zeros(npoints)
result=[]
#Set the initial conditions
for step in range(0,len(n1)):
     x0[0] = x1[step]
     y0[0] = y1[step]
     z0[0] = z1[step]

     vx0[0] = vx1[step]
     vy0[0] = vy1[step]
     vy0[0] = vz1[step]



print x0

这会打印出结果

[-2.72482266  0.          0.          0.          0.          0.
  0.          0.          0.          0.        ]

但是,我 想要 的输出是我在循环中包含 "print x0" 时得到的。喜欢:

npoints=10

x0 = np.zeros(npoints)
y0 = np.zeros(npoints)
z0 = np.zeros(npoints)
vx0 = np.zeros(npoints)
vy0 = np.zeros(npoints)
vz0 = np.zeros(npoints)
result=[]
#Set the initial conditions
for step in range(0,len(n1)):
     x0[0] = x1[step]
     y0[0] = y1[step]
     z0[0] = z1[step]

     vx0[0] = vx1[step]
     vy0[0] = vy1[step]
     vy0[0] = vz1[step]



    print x0

我的结果是期望的:

[-0.29914467  0.          0.          0.          0.          0.
  0.          0.          0.          0.        ]
[2.24151163 0.         0.         0.         0.         0.
 0.         0.         0.         0.        ]
[-0.01034917  0.          0.          0.          0.          0.
  0.          0.          0.          0.        ]......
[-2.72482266  0.          0.          0.          0.          0.
  0.          0.          0.          0.        ]

如何在不在 for 循环中打印的情况下存储所有这些数组,而不仅仅是最后一个数组?

然后你需要为 x0 创建一个二维数组来存储所有这样的递归值

npoints=10

x0 = np.zeros([len(n1), npoints])
y0 = np.zeros(npoints)
z0 = np.zeros(npoints)
vx0 = np.zeros(npoints)
vy0 = np.zeros(npoints)
vz0 = np.zeros(npoints)
result=[]
#Set the initial conditions
for step in range(0,len(n1)):
    x0[step, 0] = x1[step]
    y0[0] = y1[step]
    z0[0] = z1[step]

    vx0[0] = vx1[step]
    vy0[0] = vy1[step]
    vy0[0] = vz1[step]



print x0