【发布时间】:2013-10-01 12:14:17
【问题描述】:
我正在使用 scipy 来求解一个常微分方程组。为简单起见,将我的代码设为:
import scipy as sp
import numpy as np
from scipy.integrate import odeint
from numpy import array
def deriv(y,t): # return derivatives of the array y
a = -2.0
b = -0.1
return array([ y[1], a*y[0]+b*y[1] ])
time = np.linspace(0.0,10.0,100)
yinit = array([0.0005,0.2]) # initial values
y = odeint(deriv,yinit,time)
但是现在我想解决这个系统的几个常数“a”的值。因此,例如,我不想只有一个 = -2.0,而是:
a = array([[-2.0,-1.5,-1.,-0.5]])
并求解系统中每个 a 的值。有没有办法做到这一点而不必遍历数组的每个元素?我可以一次性完成吗?
【问题讨论】:
标签: python arrays scipy odeint