Interpolating on a semilog scale

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?

 Accepted Answer

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

Exactly what I was trying to do, thank you!!
As always, my pleasure!
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!
Did you find the solution to your problem? I want to do the same

Sign in to comment.

More Answers (0)

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!