简体   繁体   English

Python与MATLAB进行插值

[英]Python vs MATLAB for interpolation

I want to leave MATLAB for full python integration in my scripts, and I realised that doing the same interpolation with the same values does not produce the same result on both languages! 我想让MATLAB在脚本中完全集成python,我意识到用相同的值进行相同的内插不会在两种语言上产生相同的结果! I am pretty sure the matlab code was correct so I am wondering if what I did on python is the same. 我很确定matlab代码是正确的,所以我想知道我在python上所做的是否相同。

The MATLAB code is: MATLAB代码为:

F = TriScatteredInterp( xPanel', yPanel', COPEN', 'natural' );
toolCOPEN = F( xTool', yTool' );
toolCOPEN( isnan( toolCOPEN ) ) = (-1)

which happens to be a one line code with griddata: 碰巧是带有griddata的一行代码:

toolCOPEN = griddata( ( xPanel, yPanel ),
                      COPEN,
                      ( xTool, yTool ),
                      method = 'linear',
                      fill_value = '-1'
                      )

The final toolCOPEN differs and I am really wondering why..? 最终的工具COPEN不同,我真的想知道为什么。 I would guess they both use Delaunay Triangulation which should produce the same results... 我猜他们俩都使用Delaunay Triangulation来产生相同的结果...

Thank you for your help! 谢谢您的帮助!

您在Matlab中使用的是natural邻居插值,但是在Python中使用的是linear插值,这可能会导致结果差异。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM