网络编程
位置:首页>> 网络编程>> Python编程>> python中的插值 scipy-interp的实现代码

python中的插值 scipy-interp的实现代码

作者:齐天大圣徐  发布时间:2022-02-23 02:50:09 

标签:python,插值,scipy,interp

具体代码如下所示:


import numpy as np
from matplotlib import pyplot as plt
from scipy.interpolate import interp1d
x=np.linspace(0,10*np.pi,num=20)
y=np.sin(x)
f1=interp1d(x,y,kind='linear')#线性插值
f2=interp1d(x,y,kind='cubic')#三次样条插值
x_pred=np.linspace(0,10*np.pi,num=1000)
y1=f1(x_pred)
y2=f2(x_pred)
plt.figure()
plt.plot(x_pred,y1,'r',label='linear')
plt.plot(x,f1(x),'b--','origin')
plt.legend()
plt.show()
plt.figure()
plt.plot(x_pred,y2,'b--',label='cubic')
plt.legend()
plt.show()


python中的插值 scipy-interp的实现代码
python中的插值 scipy-interp的实现代码

总结

以上所述是小编给大家介绍的python中的插值 scipy-interp的实现代码网站的支持!

来源:https://blog.csdn.net/sinat_26492471/article/details/81164803

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com