以一次线条插值为例:

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from scipy.interpolate import splrep,splev

def f(x):
return np.sin(x) + 0.5 * x

x=np.linspace(-2np.pi,2np.pi,50)
ipo = splrep(x, f(x),k=1)
iy=splev(x,ipo)

plt.plot(x, f(x), 'b' , label='f(x)')
plt.plot(x, iy, 'r.' , label='interpolation')
plt.legend(loc=0)
plt.grid(True)
plt.xlabel('x')
plt.ylabel('f(x)')

数学工具(二)插值

相关文章:

  • 2021-12-24
  • 2021-09-18
  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
  • 2022-01-31
  • 2021-07-19
猜你喜欢
  • 2022-12-23
  • 2021-05-19
  • 2021-05-01
  • 2022-02-09
  • 2021-07-13
  • 2021-11-18
  • 2021-11-28
相关资源
相似解决方案