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?
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)')