- 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!