什么是Python插值函数,它与Matlab中的spapi相同

问题描述 投票:1回答:1

在Matlab中,我可以使用样条插值函数spapi生成样条曲线,以便可以匹配曲线的规定值及其前两个导数。例如:

spapi([0 0 0 0 1 2 2 2 2],[0 1 1 1 2],[2 0 1 2 -1])

这会在区间[0..2]上生成唯一的三次样条f,其中只有一个内部结,为1,满足五个条件

f(0)= 2,f(1)= 0,f'(1)= 1,f''(1)= 2,f(2)= - 1

这些包括在1处的3倍匹配,即,与那里的函数及其前两个导数的规定值匹配。

然而,在Python中,样条插值函数scipy.interpolate.splrep(x,y)无法工作,因为x应该单调递增。

那么,我怎样才能得到具有规定值和导数值的曲线?有没有Python模块或功能?

非常感谢!

python matlab scipy interpolation spline
1个回答
0
投票

scipy.interpolate.BPoly.from_derivatives构造一个Hermite样条曲线,您可以在其中选择衍生物的值:

https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.BPoly.from_derivatives.html

在您的示例中,您有两个间隔,0..1和1..2。

© www.soinside.com 2019 - 2024. All rights reserved.