Convert a value in a logarithmic sequence to a linear equivalent

488 Views Asked by At

Sorry if im asking a silly question. Its been a while since varsity maths.

I have a logarithmic sequence ranging from [1 to 32]. It is a signal strength value from a modem.

I need to display this value as a linear percentage.

What sort of algorithm or maths function would I use to obtain the linear percentage equivalent of the logarithmic input.

So my functions input would be 1 to 32, and the output would range from 0 to 100.

ie f(32) = 100

I am not to sure what to map f(0) to, as there can't technically be a 0% signal strength connection because then there wouldn't be a connection?

2

There are 2 best solutions below

5
On

If you really want a linear $f$ such that $f(32) = 100$ and $f(0) = 0$, $f(x) = \frac{100}{32} x$. Note that this does not reflect the actualy "signal strength" percentage from signals (I assume you have it in $-x\ \mathrm {dB}$)

3
On

I assume you want to map $0$ to $0\%$ and $32$ to $100\%$. In that case, all you need to do is multiply your number with $\frac{100}{32}$ to get the percentage.

For example, $f(16) = 16\cdot\frac{100}{32} = 50$.