フィルターのクリア

Interpolate Data and find the matching x-Value

5 ビュー (過去 30 日間)
Gabriel Bischof
Gabriel Bischof 2020 年 1 月 22 日
コメント済み: Star Strider 2020 年 1 月 22 日
I have got an arry with 151937x2 double wicht discribes a Curve.
I am trying to find the x-Value to the matching y- Value for example:
data=[1 2,
2 3,
3 3,
4 5,
7 9]
I have tryed it with:
interp1(data(:,1), data(:,2),y-Value ,'PCHIP')
But the function returns the according y-Value, logically. So I tryed to swap x and y datas. The Problem is that the y-Values arent unique.
I hope someone can help me.

採用された回答

Star Strider
Star Strider 2020 年 1 月 22 日
Try this:
data=[1 2,
2 3,
3 3,
4 5,
7 9];
xval = @(yval) fsolve(@(x) interp1(data(:,1), data(:,2), x, 'linear') - yval, median(data(:,1)));
that with these calls to it:
Out3 = xval(3)
Out6 = xval(6)
Out8 = xval(8)
produces:
Out3 =
3.0000
Out6 =
4.7500
Out8 =
6.2500
  4 件のコメント
Gabriel Bischof
Gabriel Bischof 2020 年 1 月 22 日
I understand. Thank you a lot, this was a great help.
Star Strider
Star Strider 2020 年 1 月 22 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by