How to fix error about interp1?
Afficher commentaires plus anciens
Hello,
I have some data and i want to run this code:
xi = [85];
yi = interp1(y,x,xi)
but I have this error:
Error using griddedInterpolant
The grid vectors are not strictly monotonic increasing.
Error in interp1 (line 183)
F = griddedInterpolant(X,V,method);
Error in Q4 (line 19)
yi = interp1(y,x,xi)
How can I fix it?
Réponse acceptée
Plus de réponses (1)
John D'Errico
le 12 Mar 2017
0 votes
The fix is easy. Don't use interp1 to interpolate data that is not strictly monotone in the independent variable.
After all, how can interp1 know which value to predict on a function that is apparently multi-valued? For example, consider points around the perimeter of acircle. For any given x, there are TWO solutions. Interp1 requires a single valued function for any given x.
Catégories
En savoir plus sur Discrete Data Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!