Convert power to decibels




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


expand all

Power Spectrum of a Noisy Sinusoid

Generate 1024 samples of a noisy sinusoid having a normalized frequency of $2\pi/3$ 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);

xlabel('\omega / \pi')
ylabel('Power (dB)')

Repeat the computation using pwelch without output arguments.


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.

See Also

| | |

Was this topic helpful?