フィルターのクリア

griddedInterpolant (via e.g. interp1) bug with NaNs?

11 ビュー (過去 30 日間)
Karl
Karl 2013 年 3 月 12 日
編集済み: madhan ravi 2019 年 1 月 6 日
I hope I've done due diligence searching for the source of this behavior; I haven't seen this question asked or answered.
Is interp1 with method 'linear' correct in its sensitivity to NaN order when basis and interpolant points are equal?
The plot generated by the following code demonstrates that, although the value for x=2 is present in the source data y, it is returned as NaN by the interpolant for xi=2.
x = 1:5;
y = [2,1,NaN,1,2];
xi = 1:0.5:5;
yi = interp1(x,y,xi,'linear');
plot(x,y,'.-k');hold on;
plot(xi,yi,'s-r'); hold off
Is this the expected behavior? In looking at the interp1 code, it seems that the fault, if it exists, may lie within griddedInterpolant.
  1 件のコメント
Walter Roberson
Walter Roberson 2013 年 3 月 12 日
Behavior with a NaN is not defined in the documentation.

サインインしてコメントする。

回答 (3 件)

dominik
dominik 2013 年 5 月 30 日
Hey, I have the same problem: I define a griddedinterpolant IP over a grid G and the values V. whenever I evaluate IP at a gridpoint x that has an adjacent gridpoint y for which V(y) = NaN, I get IP(x)=NaN, even though V(x) is not NaN. Can that be avoided? I Use matlab 2012a.

Trevor Harris
Trevor Harris 2018 年 4 月 10 日
Seems as if this answer still isn't solved. I'm in 2017b and am having the same problem. As you can see by the attached screenshot, the value for 300 does indeed exist, but when I reference it, I get a NaN. Any idea why this behaviour exists?
Trevor

Vladimir Kazei
Vladimir Kazei 2019 年 1 月 6 日
編集済み: madhan ravi 2019 年 1 月 6 日
You can use fillmissing(y, 'linear') since 2016b version

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by