Hello Dan,

Yes, your description matches the expected behavior of calculating  
decibels, which is usually the logarithmic ratio of two power values.

I was trying to re-implement Matlab's implementation of the function db().
The described behavior of 'Voltage'-mode as default, and ignoring R in  
'Power' mode is just what Matlab does.
The order of inputs is given by the description of 'help db' in Matlab  
(see http://pastebin.com/hGV6ZJnv ).

That my routine lacks proper error checking, is because it was just a  
quick and dirty hack to get my existing Matlab scripts running without  
changing them.
I'm very new to Matlab/Octave, and I try to understand Matlab scripts  
written by friends of mine for a University lecture.

Would it be possible to include an implementation of db() in future  
releases of Octave?

The function is not very complicated and it's inclusion in Octave might  
save other people like me some time.

Kind regards,
Wolfgang Wallner


> Date: Wed, 27 Apr 2011 03:21:14 -0500
> From: Daniel J Sebald <[email protected]>
> Subject: Re: [OctDev] Signal Processing: Implementation of db():
>       Convert a value to decibel
> To: Wolfgang Wallner <[email protected]>
> Cc: [email protected]
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Wolfgang,
>
> The value in question should actually be a ration of two values, i.e., a
> relative measure.  Technically, a ratio of two powers, the formula being
> 10 * log10 (P1/P2).  This is the "Power" version of the formula, and I'm
> guessing the value input is P1/P2.  For reference, at half power one
> commonly says "3 db down", meaning 10*log10(0.5) is approximately -3 db.
>
> In circuit analysis, power is P = I * V = V/R * V = V^2/R.  So if the
> input option is "Voltage", then the formula becomes 10 * log10
> (V1^2/V2^2) = 20 * log10 (V1/V2), and I'm guessing the value input is
> V1/V2.  (Note how the resistance R cancels out.)
>
> Resistance value?  Got me.  Perhaps it is in reference to some kind of
> absolute value?  10 * log10 (V^2 / R) maybe, where V is now the input
> value.  I'm just guessing on that one...  I just looked at your
> implementation and what I said agrees with what you have:
>
> 10 * log10 (V^2 / R) = 10*log10(V^2) - 10*log10(R)
>       = 20*log10(V) - 10*log10(R)
>
> One thing I question is forcing the resistance value to be R = 1 in the
> case the user enters one of the "power" string qualifiers.  That type of
> behavior (ignoring the value of R) should be documented, otherwise it
> can trip users up.  Couldn't you replace
>
>                  R = 1;          % Ignore any value for R
>
> with
>
>    if (nargin == 3)
>      error('Resistance value is insignificant when power specified.');
>
> or something similar?
>
> Another question is whether the order of the options must be unit string
> followed by resistance value.  If that is your preference that is fine,
> but there is no ambiguity with, say, db(5, 50, 'Voltage') versus db(5,
> 'Voltage', 50).  The only rule being that the resistance value follows
> the voltage value.
>
> Also, in the case of bad inputs, your routine is returning without
> defining the returning value.  Isn't that considered an error by the
> interpreter?  Or is that what you are intending?
>
> I'm also slightly confused why "Voltage" should be the default for a
> routine which is by definition a ration of two powers, unless perhaps
> this routine is very circuits oriented in which case working with
> "voltage gains" is more common.
>
> Dan
>

>


-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Octave-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to