我有一个数组是(219812,2)
,但我需要分割为2 (219812)
。在Python中分割数组
我不断收到错误ValueError: operands could not be broadcast together with shapes (219812,2) (219812)
我怎样才能做到?你可以看到,我需要从u = odeint中取出两个单独的解决方案,并将它们复合。
def deriv(u, t):
return array([ u[1], u[0] - np.sqrt(u[0]) ])
time = np.arange(0.01, 7 * np.pi, 0.0001)
uinit = array([ 1.49907, 0])
u = odeint(deriv, uinit, time)
x = 1/u * np.cos(time)
y = 1/u * np.sin(time)
plot(x, y)
plt.show()
得到它的阴谋,但情节是错误的。 – dustin 2013-04-11 16:59:28
@dustin确保你没有计算/绘制其他东西。这显示了如何“分割”一个数组,我认为这可以回答你的问题。没有更多信息,我们将无法帮助您解决您的其他问题。 – jorgeca 2013-04-11 17:15:41
@dustin你想'plt.plot(time,u [:,0])'? – jorgeca 2013-04-11 17:31:57