필터 지우기
필터 지우기

How do I set F.ExtrapolationMethod to 'none' in function 'griddedInterpolant'?

조회 수: 7 (최근 30일)
Function: griddedInterpolant Q: How/where do I do set F.ExtrapolationMethod to 'none'?
"The behavior of griddedInterpolant has changed. All interpolation methods now support extrapolation by default. Set F.ExtrapolationMethod to 'none' to preserve the pre-R2013a behavior when F.Method is 'linear', 'cubic' or 'nearest'. Before R2013a, evaluation returned NaN values at query points outside the domain when F.Method was set to 'linear', 'cubic' or 'nearest'."

채택된 답변

Stephen23
Stephen23 2017년 5월 3일
편집: Stephen23 2017년 5월 3일
The griddedInterpolant documentation shows that the extrapolation can be specified by the last argument, after the interpolation method:
F = griddedInterpolant(___,Method,ExtrapolationMethod)
so you will need something like this:
F = griddedInterpolant(___,'linear','none')
Alternatively try changing the object property:
F.ExtrapolationMethod = 'none';
  댓글 수: 2
Nina Jensen
Nina Jensen 2017년 5월 3일
I still get the error code "Error using griddedInterpolant. The grid vectors must contain unique points"
My script is:
%interpolating modelled at observed depth
for j = 1:length(time_obs)
T_subsurf_mod(:,j) = interp1(depth_act(:,j),T_ice(:,j),depth_obs(:,j));
end
T_subsurf_mod and depth_obs are both 11x8784 double and depth_act is a 201x8784 double.
Steven Lord
Steven Lord 2017년 5월 3일
That's a different problem, not related to the ExtrapolationMethod. That suggests to me that the values in depth_act(:, j) are not unique for some j. Set an error breakpoint and when MATLAB enters debug mode, check:
length(depth_act(:, j))
length(unique(depth_act(:, j)))
My guess is that the two lengths will be different.

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

추가 답변 (0개)

카테고리

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