相关疑难解决方法(0)

使用Python的样条线(使用控制结和端点)

我正在尝试执行以下操作(从维基百科中提取的图像)

仿样

#!/usr/bin/env python
from scipy import interpolate
import numpy as np
import matplotlib.pyplot as plt

# sampling
x = np.linspace(0, 10, 10)
y = np.sin(x)

# spline trough all the sampled points
tck = interpolate.splrep(x, y)
x2 = np.linspace(0, 10, 200)
y2 = interpolate.splev(x2, tck)

# spline with all the middle points as knots (not working yet)
# knots = x[1:-1]  # it should be something like this
knots = np.array([x[1]])  # not working with above line and just seeing …
Run Code Online (Sandbox Code Playgroud)

python math numpy spline cubic-spline

14
推荐指数
3
解决办法
9258
查看次数

标签 统计

cubic-spline ×1

math ×1

numpy ×1

python ×1

spline ×1