ScatteredInterpolant is giving NaN as an answer when using 'natural' method.

9 次查看(过去 30 天)
Hello,
I'm using scatteredIntepolant to interpolate an electric field. when using 'linear' as a method to interpolate the field, I get an answer and all is fine but precision wise it's not so great. For that, I decided to use the 'natural' method, as it is stated to be more accurate, though for whatever reason, I keep getting NaN as an answer.
To interpolate the field, I create an interpolant as follows:
interpE = scatteredInterpolant(Xout(:),Yout(:),Zout(:),Ex_Field_out(:),'natural');
then I interpolate the field at a position (x0,y0,z0) using interpE(x0,y0,z0) for any x0 y0 z0 falling into the zone of interpolation, i.e., within the range of positions of Xout, Yout and Zout.
The answer, for some reason, is always NaN, unless it was calculated over the same data points, i.e., interpE(Xout(1),Yout(1),Zout(1)) will give basically the correct answer, as that was basically the input.
I tried also to interpolate only the real or imag part of Ex_Field_out, although I think that is already done internally in the function, but yet even with that, it still gives NaN.
Any help? Thank you.
  5 个评论
Walter Roberson
Walter Roberson 2023-9-12
Unfortunately I am not familiar with natural neighbour interpolation, and do not understand the wikipedia description at the moment.
Mhamad Hantro
Mhamad Hantro 2023-9-12
Thanks for trying though :)
I don't know much about the algorithm either, I just looked it up in Matlab's documentation, and read in some blog that although it's more accurate but still it's not the default method due to the fact that it came much later. I did try a simple example where I created a random function, and the interpolation worked, though for some reason, it's not working here.
Thanks again :)

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品


版本

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by