How to convert decibel values into positive values? [closed]
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this questionI'开发者_Python百科m getting the decibel values in negative. I just want to plot these values on a graph ranging from 0 to 100. So is there any way to convert the decibel values into positive values?
It's quite common for 0 dB
to correspond to full scale input (remember that a plain dB scale actually defines a ratio, not an absolute value, so the meaning of 0 dB
is somewhat arbitrary). For e.g. 16 bit audio, values might typically range from 0 dB
to -96 dB
. To represent this on a scale of 0 - 100
you could just add 96 dB
to bring this range up to 0..+96 dB
.
This is not a solution specific to decibels, but if you want your scale to be from 0-100, take your minimum value (lets call it minVal
), and add -minVal
to get 0. Then divide it by your maximum value, and multiply by 100.
Just use fabs() C++ method
fabs function double fabs ( double x ); float fabs ( float x ); long double fabs ( long double x ); Compute absolute value
Returns the absolute value of x ( /x/ ).
In C++, abs is also declared in this header with the same behavior.
Parameters x Floating point value.
Return Value The absolute value of x.
Portability In C, only the double version of this function exists with this name.
fabs reference
精彩评论