フィルターのクリア

how to find value of y from a graph with a known x value

6 ビュー (過去 30 日間)
Ross Hanna
Ross Hanna 2017 年 8 月 12 日
コメント済み: Ross Hanna 2017 年 8 月 13 日
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

採用された回答

Chad Greene
Chad Greene 2017 年 8 月 12 日
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);
  1 件のコメント
Ross Hanna
Ross Hanna 2017 年 8 月 13 日
im relatively new to matlab, and trying to execute this is problematic. if i import my data e.g. Force and Velocity, then type in your code, it comes up as "undefined function or variable 'di'". What should i set di equal to? if i set it equal to say 400N it says
Error using griddedInterpolant The grid vectors must contain unique points.
Error in interp1 (line 161) F = griddedInterpolant(X,V,method);
do i have to set it equal to a point in the data i have?
what i am trying to do is write a code that i can give it any value from 1-1400 for example and it will give me the y values associated with them and then i can average them. i looked at your other answer using the scatstat1 function but i dont know if i have to download a file that has it in for example?
Thanks for your reply

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDirected Graphs についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by