Python SciPy interp2d(线性)结果与MatLab interp2(线性)结果不同

Python SciPy interp2d(线性)结果与MatLab interp2(线性)结果不同,python,numpy,scipy,linear-interpolation,Python,Numpy,Scipy,Linear Interpolation,我正在将一个MatLab程序转换为Python,我在理解为什么scipy.interpolate.interp2d(线性)给出的结果与MatlabInterp2(线性)不同时遇到了问题。 我知道scipy.interpolate.RectibivariateSpline给出的结果与MatlabInterp2(立方)相同,但在线性方法中给出的结果不同。 向你问好,谢谢你,泽纳布 python: matlab: att=[239.044127 236.386160 231.891308 224.

我正在将一个MatLab程序转换为Python,我在理解为什么scipy.interpolate.interp2d(线性)给出的结果与MatlabInterp2(线性)不同时遇到了问题。 我知道scipy.interpolate.RectibivariateSpline给出的结果与MatlabInterp2(立方)相同,但在线性方法中给出的结果不同。 向你问好,谢谢你,泽纳布 python:

matlab:

att=[239.044127 236.386160  231.891308  224.461261  212.628196  194.850501  170.332448  140.179075  107.822158  77.686597   52.989905   34.704514   22.112333   13.845297   8.577347    5.280345    3.238684    1.982192    1.211678    0.740152      
279.480169  276.646675  271.848543  263.898990  251.189969  231.976788  205.219180  171.832314  135.280008  100.344172  70.805784   48.145550   31.927007   20.837779   13.469048   8.656136    5.544346    3.544295    2.263191    1.444215
326.756261  323.764230  318.690817  310.265908  296.745218  276.177018  247.251256  210.633036  169.730239  129.609910  94.611588   66.792291   46.097975   31.361771   21.150511   14.190114   9.491439    6.337440    4.227221    2.818012
382.029446  378.906692  373.604492  364.779470  350.562265  328.799039  297.892154  258.195183  212.953520  167.411105  126.421205  92.660904   66.558802   47.200839   33.212749   23.262033   16.248519   11.331774   7.895667    5.498620
446.652489  443.440837  437.980353  428.871037  414.139452  391.447518  358.905095  316.497136  267.183987  216.237154  168.925618  128.548413  96.101273   71.039332   52.154139   38.133744   27.816052   20.261982   14.747643   10.729132
522.206988  518.966226  513.448831  504.223460  489.246854  466.032868  432.414435  387.964004  335.224713  279.303496  225.720556  178.335132  138.756323  106.917309  81.897894   62.513127   47.618665   36.229800   27.545866   20.935121
610.542076  607.354851  601.921297  592.815265  577.975567  554.829510  520.979629  475.568500  420.592603  360.763363  301.610673  247.404216  200.344040  160.915237  128.604656    102.478559    81.519018   64.781346   51.450576   40.849466];

r=logspace(0,log10(200),20);
m=[4.5:0.5:7.5]';
[r_grid,m_grid]=meshgrid(r,m);
rr=16;
mm=4.6;
att_cubic=interp2(r_grid,m_grid,att,rr,mm,'cubic')
att_linear=interp2(r_grid,m_grid,att,rr,mm)
输出(matlab):

输出(python):


对此我没有答案(抱歉,没有足够的声誉发表评论),但是,当我运行Python代码时,我得到以下警告:

Warning:     No more knots can be added because the number of B-spline coefficients
    already exceeds the number of data points m. Probably causes: either
    s or m too small. (fp>s)
    kx,ky=1,1 nx,ny=19,11 m=140 fp=2.359644 s=0.000000
我不完全清楚这里发生了什么,但这里有一些链接可能有助于您的调查:


  • 让我知道这是否有帮助和/或您是否已经解决了这一问题。

    您能提供一个简单的示例,用matlab和python显示输入和输出吗?
    att_cubic =57.4565
    att_linear =58.2270
    
    Att_cubic=[[ 57.45649122]]
    Att_linear=[ 56.13548995]
    
    Warning:     No more knots can be added because the number of B-spline coefficients
        already exceeds the number of data points m. Probably causes: either
        s or m too small. (fp>s)
        kx,ky=1,1 nx,ny=19,11 m=140 fp=2.359644 s=0.000000