As the documentation states, periodogram
provides a power spectral density estimate pxx
:
[pxx, w] = periodogram(x);
meaning that it shows how the total variance of the signal, var(x)
, is distributed over the frequency w
. This implies that the integral of the estimated spectral density over the frequency axis
trapz(w, pxx)
should correspond to that total variance.
This also means that the psd is not normalized, neither to a total variance of 1, nor to a maximum peak of 1 (= 0 dB). That the result is plotted (not computed!) in dB merely means that the vertical axis shows $10 \, \log_{10}($ pxx
$)$, not that it shows a ratio. There is therefore no reason to expect a peak to align with 0 dB; depending on the range of values of the signal it can be both much higher and much lower.
To produce a plot from pxx
and w
, use
plot(w, 10 * log10(pxx))
xlabel('normalized frequency [rad / sample]')
ylabel('power spectral density [(rad/sample)^{-1}] in dB')
Reducing the level of the total signal by 3 dB means to divide the signal x
by a factor of 2. If you do this numerically
periodogram(x)
hold all
periodogram(x / 2)
you will see that the second psd estimate has exactly the same shape as the first, it's just 3 dB lower. If this is not what you find with your measurement data, then this means that either your volume regulation or your ADC do not work correctly.
If you are really sure you want a normalized spectrum, do the following: First, compute the psd estimate:
[pxx, w] = periodogram(x);
Then, normalize the psd, e.g. with respect to the highest peak:
npxx = pxx / max(pxx);
You can then plot the normalized psd on a logarithmic scale like this:
plot(w, 10 * log10(npxx))
xlabel('normalized frequency [rad / sample]')
ylabel('normalized power spectral density')
Note that npxx
does not have a unit.
A note about units: The unit of numbers returned as pxx
by periodogram
& friends depends on the units of the input signal x
. Let's say these are dimensionless numbers; then the unit of the numbers in the pxx
output is $\rm \frac{1}{rad / sample}$, because it is a density over w
which is in units of $\rm rad / sample$. Or let's say these are voltage measurements coming from a calibrated ADC, so that the numbers in x
are in volts. Then the unit of the numbers in the pxx
output is $\rm \frac{V^2}{rad / sample}$.
If you additionally specify the sampling frequency in the call to periodogram:
[pxx, f] = periodogram(x, [], [], fs);
and fs
is in Hz, the pxx
is a density over frequency f
, and its unit is $\rm \frac{V^2}{Hz}$.
Now if pxx
is plotted, it is often plotted logarithmically, like stated above. If the function $10 \log_{10}$ is used, then it is said that the result is in decibel, dB. Then sometimes the unit of 10 * log10(pxx)
is written as $\rm \frac{dB}{rad / sample}$. Strictly speaking, this expression doesn't make sense because dB is not just a unit (a different measurement stick) but denotes the use of a different quantity: the logarithm. That's why above I wrote the unit as [(rad/sample)^{-1}] in dB
.