Kurve fitten *matplotlib
Verfasst: Samstag 23. Mai 2020, 16:55
Moin!
Ich möchte gerne eine Kurve fitten und plotten. Leider bekomme ich dabei eine Fehlermeldung, die ich nicht ganz kapiere.
Hier ist mein Skript:
Die Fehlermeldung kommt dann in der Zeile "return a * np.exp(-b * x) + c"
Ich stehe gerade ein bisschen auf dem Schlauch, vielleicht weiß ja einer von euch weiter.
Danke sehr!
Viele Grüße
Ilona
Ich möchte gerne eine Kurve fitten und plotten. Leider bekomme ich dabei eine Fehlermeldung, die ich nicht ganz kapiere.
Hier ist mein Skript:
Code: Alles auswählen
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
import numpy as np
def func(x, a, b, c):
return a * np.exp(-b * x) + c
xdata = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]
ydata = [1.638, 1.496, 1.392, 1.306, 1.232, 1.202, 1.171, 1.057]
popt, pcov = curve_fit(func, xdata, ydata)
popt
plt.plot(xdata, func(xdata, *popt), 'r-')
Code: Alles auswählen
TypeError: can't multiply sequence by non-int of type 'numpy.float64'
<Figure size 432x288 with 0 Axes>
Danke sehr!
Viele Grüße
Ilona