2
$\begingroup$

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
$\endgroup$

migrated from electronics.stackexchange.com Sep 19 '13 at 13:38

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

1
$\begingroup$

The second trace is probably the phase. You can express the spectral density either as a sine term and a cosine term (in phase and out of phase terms) or as a magnitude and phase angle. In your first example, for your plot you have converted the sin/cos terms into a magnitude, and discarded the phase information.

Yes, log power differs from log voltage by a factor of two. $ 2 \log{(V)} = \log{(V^2)} $. But different ways of calculating FT and inverse FT, or PSD and inverse PSD, put a constant value of $ \pi $ in different places: If you use different methods of calculation, you sometimes find that you have choosen to normalize the FT differently.

$\endgroup$

Your Answer

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