필터 지우기
필터 지우기

"Linear" algorithm for griddedInterpolant

조회 수: 5 (최근 30일)
David Epstein
David Epstein 2018년 7월 23일
댓글: David Epstein 2018년 7월 23일
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
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
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?
The 'ExtrapolationMethod' is explained here: doc griddedInterpolant: Extrapolation (link)
  댓글 수: 3
Steven Lord
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.
David Epstein
David Epstein 2018년 7월 23일
Default imrotate works differently from default griddedInterpolant. imrotate gives black corners on a 45 degree rotation of a square graphics matrix, whereas, if you use griddedInterpolant, the corners, after rotation, will probably be brighter than anywhere else. The difference remains when you instruct both functions to use the linear method. The documentation has nothing to say about this, which is what puzzled me, and explains why I asked on the forum.
On another point, my objection to your method is that I think it produces a discontinuous function on the plane, anathema to a mathematician. Padding with zeros before applying griddedInterpolant produces a continuous function. The amount of padding needed depends on the interpolation algorithm.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by