Using interp1 on a function that is not monotonic increasing

조회 수: 17 (최근 30일)
jgillis16
jgillis16 2015년 9월 7일
답변: Steven Lord 2015년 9월 7일
I need to use the interp1 function on my two data sets, labeled x and y.
I wrote the following code:
yDesired = interp1(x,y, 0.009);
But, I receive the following error:
Error using griddedInterpolant
The grid vectors are not strictly monotonic increasing.
Error in interp1 (line 183)
F = griddedInterpolant(X,V,method);
Is there any way around this?

답변 (2개)

Stephen23
Stephen23 2015년 9월 7일
편집: Stephen23 2015년 9월 7일

Steven Lord
Steven Lord 2015년 9월 7일
The X input to INTERP1 must be monotonic increasing. The Y input does not need to be monotonic increasing. Call SORT with two outputs and X as input; the first output is the reordered X vector and the second output will let you reorder Y to match the reordered X.

카테고리

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