'numpy.float64' 对象在曲线拟合时不可调用

问题描述

我正在尝试在 CSV 数据中拟合正弦曲线以找到曲线的最大值。数据类似于

      Time    Voltage Current
0   -0.02500    -1.4    0.38
1   -0.02498    -1.6    0.32
2   -0.02496    -1.8    0.40
3   -0.02494    -1.4    0.44
4   -0.02492    -1.6    0.30
5   -0.02490    -2.0    0.40
6   -0.02488    -1.8    0.44
7   -0.02486    -1.4    0.32
8   -0.02484    -1.4    0.42
9   -0.02482    -1.6    0.46
10  -0.02480    -1.8    0.36

这是代码

from numpy import sin
from scipy.optimize import curve_fit
from matplotlib import pyplot


# input and output variables
x,y = dfi["Time"],dfi["Voltage"] 


# defining the function
def func(x,a,b,c,d):
   return a * sin(b(x-c)) + d

# curve fit
popt,_ = curve_fit(func,x,y)

它给了我这个错误

<ipython-input-20-f95822761dd9> in objective(x,d)
      9 # defining the function
     10 def objective(x,d):
---> 11         return a * sin(b(x-c)) + d
     12 
     13 # curve fit

TypeError: 'numpy.float64' object is not callable

这是我第一次尝试曲线拟合,我不明白这个错误

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)