Seite 1 von 1

curve-fitting

Verfasst: Donnerstag 5. September 2013, 12:54
von Grizzly
hallo,
ich würde gerne eine Kurve durch folgende Punkte legen und eventuell auch über die Punkte hinaus interpolieren...
Wie geht man am besten vor ?

Code: Alles auswählen

import numpy as np
import matplotlib.pyplot as plt

# some data
T = np.array([0.0, -2.0, -5.0, -10.0, -15.0, -20.0, -25.0, -30.0, -35.0, -40.0, -45.0, -50.0])
A = np.array([2400, 1700, 930, 350, 210, 120, 68, 37, 20, 10, 5.2, 2.6])

# plotting
fig = plt.figure()              
ax = plt.scatter(T,A)
plt.show()

Re: curve-fitting

Verfasst: Freitag 6. September 2013, 10:50
von Grizzly
Soweit schaffe ich es selber... ist aber leider noch nicht das Gelbe vom Ei !

Code: Alles auswählen

import numpy as np
import matplotlib.pyplot as plt

x = np.array([0.0, -2.0, -5.0, -10.0, -15.0, -20.0, -25.0, -30.0, -35.0, -40.0, -45.0, -50.0])
y = np.array([2400, 1700, 930, 350, 210, 120, 68, 37, 20, 10, 5.2, 2.6])

z = np.polyfit(x, y, 5)
p = np.poly1d(z)
p30 = np.poly1d(np.polyfit(x, y, 8))
xp = np.linspace(-55, 5.0, 100)

plt.plot(x, y, '.', xp, p(xp), '-', xp, p30(xp), '--')
plt.xlim(-55,5)
plt.ylim(-50,2500)

plt.show()


Re: curve-fitting

Verfasst: Montag 9. September 2013, 13:45
von Grizzly
Wirklich Niemand ? :K