Solving a function by interpolation
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm trying to find the solution x of f(a, b, c, d, x) = 0 where f is a function I implemented. I managed to create an array X = xmin:xstep:xmax; Then I tried to interpolate in order to find x such that f = 0: x = interp1(f(a,b,c,d,X),X,0);
But I sometimes get an error by using interp1 (which I don't get by using a home made slower interpolation function) :
Error using griddedInterpolant The grid vectors must contain unique points.
Error in interp1 (line 151) F = griddedInterpolant(X,V,method);
Any idea how to solve this? If you have any suggestion to get the value x to solve f(a,b,c,d,x) =0 I'm listening too.
Thanks in advance
3 commentaires
Sargondjani
le 30 Juin 2020
Well the error says it: "The grid vectors must contain unique points." If a particular value of x has two 'y' values, then you can not use interp1 in that way. If x is a function of y, then swap your x and y variables in interp1 and it should work.
Réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!