필터 지우기
필터 지우기

getting slope information from griddedInterpolant

조회 수: 18 (최근 30일)
dominik
dominik 2014년 1월 30일
댓글: Matt J 2014년 1월 31일
Hey when evaluating a griddedInterpolant, the computer should at some pont determine the slope of the interpolant at the query point. is there a way to modify the griddedInterpolant such that he not only provides the value at the query point but also the slope (without any additional computations).
i.e. instead of interpolant(x)=approximation(f(x)) interpolant(x)=approximation([f(x) f'(x)])
If not, does anyone have a handmade interpolant code that runs similarilye efficient?
Thanks
Dominik
  댓글 수: 3
dominik
dominik 2014년 1월 31일
편집: dominik 2014년 1월 31일
Allright, the slope is not there but most of the calculation is done already (i assume the expensive bit is finding i, not accessing v or evaluating t or vi). All thats need to be done is (v(i)-v(i+1))/t.
Also it would be easy and not more expensive to rewrite your expression in terms of the slope.
For the spline i guess a similar point could be made (since you know the analytical expression of the interpolant between x(i) and x(i+t) you could evalute its analytical derivative at xquery) but im not sure.
But the question i guess is: can i edit the griddedInterpolant? No. So are there effieceintly coded interpolants available that can be adapted (ideally including spline and extrapolation)?
Matt J
Matt J 2014년 1월 31일
There are a variety of interpolation routines on the FEX, which you could try to modify. There are also routines dedicated to splines and their derivatives, e.g.,

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

답변 (1개)

Matt J
Matt J 2014년 1월 30일
편집: Matt J 2014년 1월 31일
griddedInterpolant is a built-in function and can't be modified.
Assuming you're talking about 1D interpolation, you can use this form of interp1 (see doc interp1)
pp = interp1(...'pp');
to get the piecewise polynomial representing the interpolated data, and then apparently this FEX file
to get derivatives, (though I haven't used it myself). Unfortunately, it appears that the above interp1 syntax is soon to be removed from MATLAB!
  댓글 수: 1
dominik
dominik 2014년 1월 31일
Thanks, unfortunatley i was speaking about the general case ( in my case 2D and 3D). Plus Interp1 is far to slow and uses griddedInterpolant.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by