我在使用scipy中的对分优化器时遇到问题。以下是我代码的相关部分:
我是怎么进口东西的
import numpy as np
import scipy.optimize as sp
import matplotlib.pyplot as plt
代码中断,导致以下错误的部分
#All variables are previously defined except for h
def BeamHeight(h):
x = 1000e3*M[i]*h/(fw*h^3-(fw-wt)(h-2*ft)^3) - Max_stress_steel
return x
for i in range(0,50):
h = np.zeros((50))
h[i] = sp.bisect(BeamHeight, hb, 5,xtol = 0.001)
导致此错误的原因:
Traceback (most recent call last):
File "ShearMoment.py", line 63, in <module>
h[i] = sp.bisect(BeamHeight, hb, 5,xtol = 0.001)
File "/usr/lib/python2.7/dist-packages/scipy/optimize/zeros.py", line 248, in bisect
r = _zeros._bisect(f,a,b,xtol,rtol,maxiter,args,full_output,disp)
File "ShearMoment.py", line 58, in BeamHeight
x = 1000e3*M[i]*h/(fw*h^3-(fw-wt)(h-2*ft)^3) - Max_stress_steel
TypeError: 'float' object is not callable
我知道scipy.optimize需要一个函数作为它的参数之一。我做得不对吗
在Python中,连接不是隐式乘法,
^
不是指数运算。乘法必须用*
显式表示,而指数运算必须写成**
。这部分BeamHeight
:必须写成
相关问题 更多 >
编程相关推荐