Accelerating the pace of engineering and science

# db

Convert energy or power measurements to decibels

## Syntax

dboutput = db(X)
dboutput = db(X,SignalType)
dboutput = db(X,R)
dboutput = db(X,'voltage',R)

## Description

dboutput = db(X) converts the elements of the vector or matrix X to decibels (dB). The elements of X are voltage measurements across a resistance of 1 ohm.

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.

dboutput = db(X,R) specifies the resistance R for voltage measurements. You can specify a resistance only when the signal measurements are voltages.

dboutput = db(X,'voltage',R) specifies the resistance R for voltage measurements. This syntax is equivalent to db(X,R).

## Input Arguments

 X Signal measurements. X must be a vector or matrix. If the elements of X are power measurements, all elements must be nonnegative. SignalType 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. Default: 'voltage' R Resistive load in ohms. You can specify resistance only when the SignalType is 'voltage'. Default: 1

## Output Arguments

 dboutput 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:$dB=10\text{ }\text{ }{\mathrm{log}}_{10}\left(|X{|}^{2}/R\right)$ If the input X contains power measurements, dboutput is:$dB=10{\mathrm{log}}_{10}\left(X\right)$

## Examples

expand all

### Decibels from Voltage and Power

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



## Alternatives

• mag2db — Converts magnitude measurements to decibels.

• pow2db — Converts power measurements to decibels.

## See Also

Was this topic helpful?