-1
已經得到了下面的代碼到目前爲止:的Python - 類型錯誤:「浮動」對象不是可調用
class beam(object):
def __init__(self, E, I, L):
self.E = E
self.I = I
self.L = L
self.Loads = [(0.0, 0.0)] #[(Force, distance along beam)]
def getTotalDeflection(self, x):
"""Calculate total deflection of beam due to multiple loads"""
loadsList = self.Loads
beam.beamDeflection(loadsList, x)
def getSlope(self, x):
"""Calculate gradient at a point x on beam due to deflection
"""
import scipy.misc
return scipy.misc.derivative(self.getTotalDeflection(x), x)
對於函數getSlope(),我需要通過相對於尋找偏轉的衍生物計算斜率到x。不過,我收到以下錯誤:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\X\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 685, in runfile
execfile(filename, namespace)
File "C:\Users\X\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 71, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)
File "C:/Users/X/Downloads/beamModel.py", line 12, in <module>
class beam(object):
File "C:/Users/X/Downloads/beamModel.py", line 67, in beam
print b.getSlope(1.0)
File "C:/Users/X/Downloads/beamModel.py", line 62, in getSlope
return scipy.misc.derivative(self.getTotalDeflection(x), x)
File "C:\Users\X\Anaconda2\lib\site-packages\scipy\misc\common.py", line 258, in derivative
val += weights[k]*func(x0+(k-ho)*dx,*args)
TypeError: 'float' object is not callable
做,但它給了同樣的錯誤。謝謝。 – Student1001