MATLAB: Interpolating on a semilog scale

interpolationsemilog

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?

Best 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.