- If you specify the 'pchip' or 'spline' interpolation methods, then the default behavior is 'extrap'.
- All other interpolation methods return NaN by default for query points outside the domain.
interp1 using method 'previous' returns an unexpected NaN?
5 ビュー (過去 30 日間)
古いコメントを表示
x = [1 2 4]; v = [17 100 17]; xq = 1:5; vq = interp1(x,v,xq,'previous');
vq = 17 100 100 17 NaN
Why is vq(5) not equal to 17?
0 件のコメント
採用された回答
Stephen23
2017 年 1 月 12 日
編集済み: Stephen23
2017 年 1 月 12 日
Your query point is outside of the input domain (from 1 to 4), so NaN is the correct and documented output.
As the documentation states, if you want to extrapolate, then you need to specify this:
vq = interp1(x,v,xq,'previous','extrap')
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Multirate Signal Processing についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!