Using interp1 on a function that is not monotonic increasing
18 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(2 个)
Stephen23
2015-9-7
编辑:Stephen23
2015-9-7
John D'Errico explains here why interpolation requires a monotonic independent variable:
It seems lots of beginners misunderstand interpolation, but the answer is always the same "the independent variable must be monotonic":
If you have scattered data, then you need to use the appropriate tool, one of these might help you:
0 个评论
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.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!