Accelerating the pace of engineering and science

# pow2db

Convert power to decibels

## Description

example

ydb = pow2db(y) expresses in decibels (dB) the power measurements specified in y. The relationship between power and decibels is ydb = 10 log10(y).

## Examples

expand all

### Power Spectrum of a Noisy Sinusoid

Generate 1024 samples of a noisy sinusoid having a normalized frequency of rad/sample. Estimate the power spectrum of the signal using pwelch. Express the estimate in decibels and plot it.

n = 0:1024-1;
x = cos(2*pi*n/3) + randn(size(n));

[pxx,w] = pwelch(x,'power');

dB = pow2db(pxx);

plot(w/pi,dB)
xlabel('\omega / \pi')
ylabel('Power (dB)')


Repeat the computation using pwelch without output arguments.

pwelch(x,'power')


## Input Arguments

expand all

### y — Input arrayscalar | vector | matrix | N-D array

Input array, specified as a scalar, vector, matrix, or N-D array. When y is nonscalar, pow2db is an element-wise operation.

Data Types: single | double

## Output Arguments

expand all

### ydb — Power measurements in decibelsscalar | vector | matrix | N-D array

Power measurements in decibels, returned as a scalar, vector, matrix, or N-D array of the same size as y.