"Linear" algorithm for griddedInterpolant
2 次查看(过去 30 天)
显示 更早的评论
Try this
M=rand(2,3);
disp(M);
F=griddedInterpolant(M);
disp([F(1,1),F(1.5,2.5),F(2,3),F(50,19),F(-50,19)]);
What is the mysterious algorithm used by Mathworks that gives the two final answers? I need an F with predictable answers.
1 个评论
Adam
2018-7-23
What do you mean by 'predictable'? You get the same answer every time for the same inputs (i.e. obviously not creating a random input every time).
(50,19) and (-50,19) are both miles away from the input matrix though so that is a lot of extrapolation needed to get there. I don't see what is especially unpredictable about it though other than the fact that extrapolating that far from your data will always be so inaccurate as to be totally unreliable.
采纳的回答
Jan
2018-7-23
编辑:Jan
2018-7-23
Of course the output is predictable and even exactly defined as expected. If you extrapolate the values, the marginal linear segments are expanded. This is the intuitive behavior. So what exactly is the problem with griddedInterpolant? What do you expect instead?
3 个评论
Steven Lord
2018-7-23
The easiest way to have the result of the extrapolation be zero is to specify that you don't want extrapolation then replace the missing values in the result of evaluating the griddedInterpolant (represented as NaN) with 0 using fillmissing or isnan.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!