Specifying range of data from a plot??

4 ビュー (過去 30 日間)
Clifford Shelton
Clifford Shelton 2012 年 5 月 8 日
コメント済み: Nom 2019 年 10 月 7 日
This is my plot:
x=1:5;
y=rand(size(x));
lh=line(x,y);
xp=get(lh,'xdata');
yp=get(lh,'ydata');
I understand the above code...but now I want to know the values of x when it has a specific relation to y.
How would I code that I want to know the values for x when y is equal or greater to a new variable n?
Something like: xSelect = get(lh,'xdata' if y>=n) ???? not sure how to code what I want.
Thanks for the help!

採用された回答

Rick Rosson
Rick Rosson 2012 年 5 月 8 日
xSelect = x(y>=n);
  3 件のコメント
Rick Rosson
Rick Rosson 2012 年 5 月 8 日
No need to be embarrassed. MATLAB is a very compact and powerful language; the initial learning curve can be challenging if you are used to working with traditional languages like C or Fortran.
Nom
Nom 2019 年 10 月 7 日
Rick, you don't know how much you just helped me out.
Such a simple answer yet I've been trying to fiddle with this for the past hour.
All I wanted to do was select the X and Y range data based on a criteria.
I ended up using:
Xrange = x((x>x(X1) & x<x(X2)));
Yrange = y((x>x(X1) & x<x(X2)));
To find the x values when x is greater than X1 but smaller than X2, and the same with the Yvalues

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by