0
$\begingroup$

I am generating a simple DC signal with noise. As expected the fft shows that there is one peak at 0Hz and some noise. I am also trying to get the spectral power density representation of that signal, and I came to a problem.

When i am using a logarithmic scale, to show power to frequency relation in dB/Hz, I am observing a gradually decreasing curve (second curve in the picture below). It shows that the lower the frequencies the less power they have in relation to same value. I don't understand it - there is supposed to be only one peak at 0Hz, all other frequencies should have the same power.

This phenomenon can be observed on a regular graph, on non-logarithmic scale. This other diagram (first curve) shows clearly that there is just one frequency with "energy". Where does this difference come from? Does it come from leakage? If so, then why it is not relevant for the non-logarithmic spectrum?

enter image description here

The matlab code below generates the signal and the graphs.

clear
home 
close all

signal_multiplier = 3;
noise_bits =8;
signal_bits = 11;

fs = 1;
T = 1/fs;
t = 1:T:(2^signal_bits)-T;
noise_vec2 = randi([-(2^noise_bits) 2^noise_bits],1,length(t));

signal = signal_multiplier*t + noise_vec2;

NFFT = length(signal);
[P, F] = periodogram(signal,[],NFFT,fs,'power');
PdBW = 10*log10(P);

figure(1)
subplot(2,1,1);
plot(F,P)
grid on
title('PSD')
xlabel('Frequency (Hz)')
ylabel('Power/Frequency')
subplot(2,1,2)
plot(F,PdBW)
grid on
title('PSD using logarithmic values()')
xlabel('Frequency (Hz)')
ylabel('Power/Frequency (dB/Hz)')
$\endgroup$
1
$\begingroup$

If you zoom in on the linear curve, you would see that it's also "gradually decreasing", just much steeper, than the logarithmic curve. The logarithm simply makes it more visible. And, yes, what you see is indeed spectral leakage. It can be reduced by using a non-trivial window function as opposed to the rectangular window being employed by default in the periodogram function. Try using a Hann window, that should reduce spectral leakage.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.