how to find value of y from a graph with a known x value
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ross Hanna
le 12 Août 2017
Commenté : Ross Hanna
le 13 Août 2017
Hi There
I already have another question up on this subject but i think i may be over-complicating what i'm trying to ask. In the file i have attached, i have a graph that i have plotted from the data in the worksheet. what i am trying to do is find for values of x, not limited to the data i have, find the corresponding y values. after some reading i think i would have to use interp1, but that came with some issues when i tried to implement it (The grid vector must contain unique points' error and then 'Vectors must be the same lengths') and also use index. would i have to interpolate first to get numbers in incrementys of 1 or 2 etc then use index=find?
thanks, Ross
0 commentaires
Réponse acceptée
Chad Greene
le 12 Août 2017
Hi Ross,
The data you provide make a multi-valued function. There are several possibly y values for any given x value, so interp1 would not be a valid way to get an answer. Even if you flip the x and y, it's still multi-valued.
Depending on your application, you might be able to think of each x value and each y value as functions of distance along the path. The distance along the path would be something like
d = [0;cumsum(hypot(diff(x),diff(y)))];
Then if you want to get the points xi,yi at some distance di, it would be
xi = interp1(d,x,di);
yi = interp1(d,y,di);
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Interpolation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!