Python CubicSpline plotten?
Hallo,
Ich habe gerade folgenden Code geschrieben:
import numpy as np
from scipy.interpolate import CubicSpline
def f(x):
return np.exp(-x)*np.sin(2*x)
x1=np.linspace(0,4*np.pi,10)
y1=f(x1)
spline1=CubicSpline(x1,y1)
Abspline1=spline1.derivative
xwerte=np.linspace(0,4*np.pi,1000)
plt.plot(xwerte,Abspline1(xwerte))
Mein Ziel war es, die Ableitung des Splines zu plotten. Nun wird mir aber immer der Fehler “The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()” angezeigt.
Ich habe nur leider keine Ahnung, wo mein Fehler liegt, oder wie ich ihn beheben kann, weil ich nicht weiß, woher der Wahrheitswert kommt.
Würde mich riesig freuen, wenn mir jemand helfen könnte!!
Vielen Dank schon mal im Voraus 🙂
You’ll have used any method wrong. Since you have only shown the error message in a shortened way, you can’t tell you what method exactly this is, but that should be there accordingly.
Somewhere a scalar is required, but you specified an array.
Okay, I’ll take a look. Thank you.