Convert energy or power measurements to decibels
dboutput = db(X)
dboutput = db(X,SignalType)
dboutput = db(X,R)
dboutput = db(X,'voltage',R)
dboutput = db(X,SignalType) specifies the signal type represented by the elements of X as 'voltage' or 'power'. The entries are not case sensitive. The default value is 'voltage'. For voltage measurements, the resistance defaults to 1 ohm. If you specify SignalType as 'power', the elements of X must be nonnegative.
Signal measurements. X must be a vector or matrix. If the elements of X are power measurements, all elements must be nonnegative.
Type of signal measurements. Valid entries for SignalType are 'voltage' or 'power'. The entries are not case sensitive. If you specify SignalType as 'power', the elements of X must be nonnegative.
Resistive load in ohms. You can specify resistance only when the SignalType is 'voltage'.
The energy or power measurements in the input X in decibels. dboutput has the same dimensions as the input X.
If the input X contains voltage (energy) measurements, dboutput is:
If the input X contains power measurements, dboutput is:
Convert voltage to decibels. Assume that the resistance is 2 ohms. Compare the answer to the definition, .
V = 1; R = 2; dboutput = db(V,2); compvoltage = [dboutput 10*log10(1/2)]
compvoltage = -3.0103 -3.0103
Convert a vector of power measurements to decibels. Compare the answer to the result of using the definition.
rng default X = abs(rand(10,1)); dboutput = db(X,'power'); comppower = [dboutput 10*log10(X)]
comppower = -0.8899 -0.8899 -0.4297 -0.4297 -8.9624 -8.9624 -0.3935 -0.3935 -1.9904 -1.9904 -10.1082 -10.1082 -5.5518 -5.5518 -2.6211 -2.6211 -0.1886 -0.1886 -0.1552 -0.1552