To find a value on x axis corresponding to a y value( found by interpolation) in a MATLAB plot

1 回表示 (過去 30 日間)
Avi
Avi 2018 年 3 月 24 日
回答済み: Avi 2018 年 3 月 25 日
I have a 57*61 array that has values in each row approximately between 40.21 to 94.34 in percentage. Each row is plotted against other vector of 1*61.
The values change unevenly in each row. Now I have to find two values that are close to 50. For first row they are at (1,6) and (1,7), but they change in each row, so how can I get the two values in each row in immediate proximity of 50. I then plan to use interpolation to find the x value (in the 1*61 vector) corresponding to the y value.

採用された回答

Jan
Jan 2018 年 3 月 24 日
For each row:
Result = zeros(1, 57);
for iCol = 1:57
Result(iCol) = interp1(Data(iCol, :), y, 50);
end
where y is your 1x61 vector.
But this replies 1 value for each column. Why do you want to find 2 values?
  1 件のコメント
Avi
Avi 2018 年 3 月 25 日
@jan thanks for you reply. I need two values as the value corresponding to exact 50 is not available in the y(1*61) vector.
I have to use the two values in another plot of the same y values and corresponding percentage (50 in this case) converted to lengths which give a non linear plot to find the x values. And also I have two x values(x1 &X2) (57*61) corresponding to same y(1*61). Sorry I forgot to mention that earlier.

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

その他の回答 (1 件)

Avi
Avi 2018 年 3 月 25 日
After thinking on the solution by @jan I was able to determine the method to be used. % this gives the logical true values for numbers those are less then 50 For i = 1:57 For j = 1:61 if x1(i,j)<= 50 abc(i,j)= x1(i,j); end end end Then I just have to sum the number of true values to find the column number along the row. And I get the coordates of the number less then 50 and +1 to the column number gives the one greater then 50 and then I get corresponding values on the y axis.

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by