Interpolating on a semilog scale
61 views (last 30 days)
Show older comments
Jenna Scott
on 30 Jan 2020
Commented: Ander de Marcos Arocena
on 18 Nov 2021
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?
0 Comments
Accepted Answer
Star Strider
on 30 Jan 2020
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 Comments
Görkem ÜLKÜTAS
on 27 May 2020
Edited: Görkem ÜLKÜTAS
on 27 May 2020
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
on 18 Nov 2021
Did you find the solution to your problem? I want to do the same
More Answers (0)
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!