Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visually midway between two points on a x axis log scale [closed]

Tags:

math

matlab

The follow plot shows my question:

enter image description here

I would like to add a line between the points of 1e-1 and 1e-2. So I thought just (1e-1+1e-2)/2.

But for a log scale that is not "midway".

How can I calculate the "visual" midway value between these, or any two points in this case? Code used is

clc; clear all;
y = logspace(-3,0,100);
x = y;
semilogx(y,x);
hold on
plot([1e-1 1e-1],get(gca,'YLim'),'k--'); 
plot([1e-2 1e-2],get(gca,'YLim'),'k--');

midway = (1e-1+1e-2)/2;

plot([midway midway],get(gca,'YLim'),'k--');

Thanks

like image 631
Steve Hatcher Avatar asked Jun 18 '15 07:06

Steve Hatcher


1 Answers

a=1e-2
b=1e-1
midway = exp((log(a)+log(b))/2)

Take the log to get the positions in log scale, then do the math.

You could simplify that formula and you will end up with a geometric mean:

midway=sqrt(a*b)
like image 156
Daniel Avatar answered Oct 28 '22 03:10

Daniel