Documentation

db

Convert energy or power measurements to decibels

Description

dboutput = db(x) converts the elements of x to decibels (dB). This syntax assumes that x contains voltage measurements across a resistance of 1 Ω.

dboutput = db(x,SignalType) specifies the signal type represented by the elements of x as either 'voltage' or 'power'.

example

dboutput = db(x,R) specifies the resistance, R, for voltage measurements.

dboutput = db(x,'voltage',R) is equivalent to db(x,R).

Examples

collapse all

Express a unit voltage in decibels. Assume that the resistance is 2 ohms. Compare the answer to the definition, $10{\mathrm{log}}_{10}\frac{1}{2}$.

V = 1;
R = 2;
dboutput = db(V,2);
compvoltage = [dboutput 10*log10(1/2)]
compvoltage = 1×2

-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 = 10×2

-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

Input Arguments

collapse all

Signal measurements, specified as a scalar, vector, matrix, or N-D array.

Data Types: single | double
Complex Number Support: Yes

Type of signal measurements, specified as either 'voltage' or 'power'. If you specify SignalType as 'power', then all elements of x must be nonnegative.

Resistive load, specified as a positive scalar expressed in ohms. This argument is ignored if you specify SignalType as 'power'.

Data Types: single | double

Output Arguments

collapse all

Energy or power measurements in decibels, returned as an array with the same dimensions as x.

• If x contains voltage measurements, then dboutput is $10\text{ }\text{\hspace{0.17em}}{\mathrm{log}}_{10}\left({|x|}^{2}/R\right).$

• If the input x contains power measurements, then dboutput is $10\text{\hspace{0.17em}}{\mathrm{log}}_{10}x.$