Find X from Y in a graph

1 回表示 (過去 30 日間)
msij
msij 2016 年 4 月 26 日
編集済み: msij 2016 年 4 月 27 日
Hi,
I have plotted some x and y values to give me a hyperbola graph (I've attached the data in the excel file). I am trying to find what the x values are from a know y value but I am having some trouble.
An example:
From either the x/y values or the plotted graph; if y = -3.951, how can I find the corresponding x value?
I have looked around and most people recommend either using find (which I can't because the new y value won't definitely be in the given y values) or interp1. When I use interp1, it returns 'The grid vectors are not strictly monotonic increasing.'.
I used the line: x = interp1(y_values,x_values, m_A);
When I use,
x = interp1(x_values,y_values, -3.951);
I am returned with 'NaN'.
I'm not sure where to go from here. All help is appreciated.
Thanks!
EDIT:
Thanks for your help. I figured it out. I have decided to just separate out the x and y values so that they are unique. Then I can plot them oppositely.

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 4 月 26 日
編集済み: Azzi Abdelmalek 2016 年 4 月 26 日
Try
x = interp1(x_values,y_values, -3.951,'linear','extrap');
  2 件のコメント
msij
msij 2016 年 4 月 27 日
I am not sure what this is doing. When I use the line above it returns an x-value of 1.6, but that isn't in the values of x on the graph.
I just need it to return the x-value for a given y, using the graph. Is this possible?
msij
msij 2016 年 4 月 27 日
From what I've seen of interp, it can predict 'y' for a given 'x'. Because my graph is a kind of hyperbola, it won't let me plot them the other way around because interp1 returns 'The grid vectors are not strictly monotonic increasing.'

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDiscrete Data Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by