1
What is the best method to interpolate Spline second-order Python? I’ve used interp1d
, but not quite what I intend.
Example of what is intended.
from scipy.interpolate import interp1d
import matplotlib.pyplot as plt
x = [5,6,7,8,9,10,11]
y = [2,9,6,3,4,20,6]
xx = [1,2,3,4,5,6,7,8,9,10,11,12]
f = interp1d(x, y, kind='quadratic')
g = f(xx)
I intend to calculate the yy
, but I get the following error:
Valueerror: A value in x_new is Below the Interpolation range.
I would like to get to python something similar to the following in Matlab
x=[5,6,7,8,9,10,11]
y=[2,9,6,3,4,20,6]
xx=[1,2,3,4,5,6,7,8,9,10,11,12]
yy = spline(x,y,xx);
plot(x,y,'o',xx,yy)
The code I executed is in the published issue.
– Sam125
Good morning, the value xx is above the interpolation range, if you leave from 5 to 11, will run, but do not know what your intention to use this range.
– Claudio Gonçalves Filho