You are here : matlabSignal Processingdb

# db() - Signal Processing

```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).```

### Syntax

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

### Example

```Decibels from Voltage and PowerOpen This Example
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```