正在将MatLab程序转换为Python。 很难理解为什么scipy.interpolate.interp1d产生了与MatlabInterp1不同的结果。
在MatLab中,用法略有不同。 yi=interp1(x,y,xi,' cubic ' ) )。
剪刀: f=interp1d(x,y,kind='cubic ' ) )。
yi=f(Xi ) ) )
在一个简单的例子中,结果是一样的。
MatLab软件: interp1([0 1 2 3 4]、[01234]、[1.5 2.5 3.5]、' cubic ' )
1.5000 2.5000 3.5000
python:interp 1d ([ 1,2,3,4 ],[ 1,2,3,4 ],kind='cubic ' ) [ 1.5,2.5,3.5 ] ) ) ) ) ) )。
阵列([ 1.5,2.5,3.5 ] ) )。
但是,在现实世界的例子中,x=0.0000 e 0002.1333 e 0013.2000 e 001.6000 e 0042.1333 e 0042.3994 e 004
Y=-6 -6 20 20 -6 -6
Xi=0.000011.7216123.4432235.16484 . (2048 datapoints )
Matlab软件:-6.0000e 000
-1.2330e 001
-3.7384e 000
.
7.0235e 000
7.0028e 000
6.9821e 000
剪刀: Array([-6.0000000e00]、
[ -1.56304101e 01],
[ -2.04908267e 00],
.
[ 1.64475576e 05]、
[ 8.28360759e 04]、
[ -5.99999999e 00]] )
你对如何获得与MatLab一致的结果有什么想法吗?
编辑:我知道三次插值算法的实现有一定的自由度。 这可能说明了我看到的不同。 这个问题可能没有意义,因为我转换的原始MatLab程序似乎应该使用线性插值。