I am new to signal processing and I am trying to get the basic concepts right.
I have a signal and I performed the FFT
of the signal in MATLAB. I also did the PSD
of the signal in MATLAB using the psd
command.
So I am confused about:
1) When we get the FFT
of the signal, It's basically showing what frequency components are inside the signal. So it's a plot of frequency against what? It is amplitude in volt right(took the abs value of the signal)? What if I want to plot dbV against frequency should I just do a mag2dB conversion on the abs value? Is the following right?
Code I tried:
Fs = 16000;
t = 0: 1/Fs : 2*(Fs-1)/Fs;
y1 = sin(2*pi*500*t );
fshift = (fftshift(fft(y1)));
f = -8000 : 1/2 : 7999;
figure;
plot(f,mag2db(abs(fshift)));
2)Now for the PSD
, I used the dspdata.psd of MATLAB and I get a plot. On the plot, I get my frequency component but the max amplitude (in dB) is not the same as the max amplitude (in dB) of the FFT
plot. Why is that? Is it because dsp
is using 10log 10 and mag2dB is using 20 log 10?
3) In the PSD
plot I am getting two plots one blue one which is quite visible and a green one, smaller in amplitude, what is this green one?
Code below:
Fs = 16000;
t = 0: 1/Fs : 2*(Fs-1)/Fs;
y1 = sin(2*pi*500*t );
psd1=spectrum(y1,1024);
hpsd = dspdata.psd(psd1,'Fs',Fs); % Create a PSD data object.
figure;
plot(hpsd); % Plot the PSD