Programmer Guide/Command Reference/EVAL/log2lin: Difference between revisions

From STX Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 6: Line 6:
:;<var>ref</var>: the reference value; must be a positive number (default=1)
:;<var>ref</var>: the reference value; must be a positive number (default=1)
:;<var>fac</var>: the factor; must be a positive number (default=20)
:;<var>fac</var>: the factor; must be a positive number (default=20)
;Result: The result ''r'' has the same type as ''x'' and contains the converted elements of ''x''
;Result: The result ''r'' has the same type as ''x'' and contains the converted elements of ''x''.
::*lin2log: ''r''<sub>i,j</sub> = fac * log<sub>10</sub>(''x''<sub>i,j</sub> / ''ref'')
::*lin2log: ''r''<sub>i,j</sub> = ''fac'' * log<sub>10</sub>(''x''<sub>i,j</sub> / ''ref'')
::*log2lin: ''r''<sub>i,j</sub> = ref * 10 ^ (''x''<sub>i,j</sub> / ''fac'')
::*log2lin: ''r''<sub>i,j</sub> = ''ref'' * 10 ^ (''x''<sub>i,j</sub> / ''fac'')


;See also: [[Programmer_Guide/Command_Reference/EVAL/npow2|log]], [[Programmer_Guide/Command_Reference/EVAL/exp|exp]]
;See also: [[Programmer_Guide/Command_Reference/EVAL/npow2|log]], [[Programmer_Guide/Command_Reference/EVAL/exp|exp]]
Line 14: Line 14:
Example:
Example:
<pre>
<pre>
#a := eval 20*log(2)    // convert factor 2 to 6dB
// #spe is a vector containing a complex spectrum
#b := eval 20*log(2,10)  // same as above
#aref := set '20e-6' // reference value: 20 micro Pascal
#c := eval 20*log(vv(2,10,20,50,100))
#logamp := eval lin2log(cr2len($#spe), $#aref) // the log. amplitude spectrum in dB
// $#c = { 6.02, 20, 26.02, 33.98, 40 }
</pre>
</pre>


[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]]
[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]]

Revision as of 15:37, 6 April 2011

Convert the elements of x to logarithmic values (e.g. dB) and vice versa.

Usage
lin2log(x {, ref {, fac}})
log2lin(x {, ref {, fac}})
x
a scalar, vector or matrix
ref
the reference value; must be a positive number (default=1)
fac
the factor; must be a positive number (default=20)
Result
The result r has the same type as x and contains the converted elements of x.
  • lin2log: ri,j = fac * log10(xi,j / ref)
  • log2lin: ri,j = ref * 10 ^ (xi,j / fac)
See also
log, exp

Example:

// #spe is a vector containing a complex spectrum
#aref := set '20e-6' // reference value: 20 micro Pascal
#logamp := eval lin2log(cr2len($#spe), $#aref) // the log. amplitude spectrum in dB

<function list>

Navigation menu

Personal tools