how to find value of y from a graph with a known x value
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ross Hanna
am 12 Aug. 2017
Kommentiert: Ross Hanna
am 13 Aug. 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 Kommentare
Akzeptierte Antwort
Chad Greene
am 12 Aug. 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);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Interpolation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!