I have a set of data, A = [25 20 10 5 2 0.5 0.07] and B = [100 90 80 72 67 56 44]. I've graphed it with A on the semilogx axis and B on the linear y axis. I would like to find the ordered pair (x1, 50), where I know the y-value but not the x-value, but using interp1 has just resulted in linear interpolation that doesn't seem to take into account the semilog scale. How can I find x1?

 採用された回答

Star Strider
Star Strider 2020 年 1 月 30 日

0 投票

The interp1 function needs to know about the log transformation. Then, it will give you the correct result.
Try this:
A = [25 20 10 5 2 0.5 0.07];
B = [100 90 80 72 67 56 44];
y1 = 50;
x1 = exp(interp1(B, log(A), y1));
figure
semilogx(A, B)
hold on
plot(x1, y1, 'p')
hold off
grid
The plot is just to demonstrate the result graphically.

4 件のコメント

Jenna Scott
Jenna Scott 2020 年 2 月 3 日
Exactly what I was trying to do, thank you!!
Star Strider
Star Strider 2020 年 2 月 3 日
As always, my pleasure!
Görkem ÜLKÜTAS
Görkem ÜLKÜTAS 2020 年 5 月 27 日
編集済み: Görkem ÜLKÜTAS 2020 年 5 月 27 日
Hello Star Strider,
Actually, I have the reverse version of this problem but I couldn't modified your answer correctly. In my case,
x = [0.6, 0.8, 1, 1.5, 2, 3, 4, 6, 8]; (log scale)
y = [0.0087, 0.0070, 0.0060, 0.0047, 0.0043, 0.0041, 0.0038, 0.0035, 0.0034]; (linear scale)
I want to interpolate for example x = 1.25 to get corresponding y value. Can you help me please.
Thank you!
Ander de Marcos Arocena
Ander de Marcos Arocena 2021 年 11 月 18 日
Did you find the solution to your problem? I want to do the same

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeInterpolation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by