Interp function error with my curve

조회 수: 1 (최근 30일)
Alex 2016년 6월 28일
편집: John D'Errico 2016년 6월 28일
Hi everyone, I would like to have the polynome of my curve:
this is the plot :
I m trying to use:
xq= 5:45
vq2 = interp1(x,y,xq);
but I receive an error: Error using griddedInterpolant The grid vectors are not strictly monotonic increasing.
Error in interp1>Interp1D (line 346) F = griddedInterpolant(Xext,V,method);
What is wrong with my vector xq?
Thank you

답변 (1개)

John D'Errico
John D'Errico 2016년 6월 28일
편집: John D'Errico 2016년 6월 28일
There is no simple polynomial that interpolates that curve. It clearly has a singularity at zero. The last time I checked, polynomials have no singularities.
Next, interp1 gets upset because you have at least some points that have the same x value. If two points have the same x value, but more than one possible y value, how do you expect interp1 to return a result? Which of that y values should it return?
Another possibility is that you might not have replicates, but that your curve has noise in the x variable, so that the curve appears to be non-monotonic in x. Again, it leaves you with a function that is not single-valued in the form y=f(x). So again, interp1 will not function.
The solution is usually to average the y values if you have replicates, replacing the replicates with a single point at that mean value. interp1 will now be happy. If it is just noise that made the x values non-monotone, then you might do a variety of things.
No matter what you do of course, you still won't get anything that is polynomial-like from that curve.
And since you have not attached the data itself, I cannot even suggest a viable model for this. (I can think of a few.) Really though, it is you who needs to pose a model, since only you know where the data comes from and what it means.


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