This behavior is due to the different conventions used by PSDFREQVEC to specify the frequency vector. FFTSHIFT shifts frequency components 1:512 to 513:1024 and components 513:1024 to 1:512. The zero frequency component occurs at the 513th array index. PSDFREQVEC uses the convention that the zero frequency component is at the 512th index.
To work around this issue, avoid using PSDFREQVEC with FFTSHIFT. The following commands return a frequency vector that is consistent with the FFTSHIFT convention for plotting frequency spectra:
FreqVec2 = linspace(-Fs/2,Fs/2-1,NFFT);
figure,plot(FreqVec2,MX,'ro')
grid on
xlabel('Frequency (Hz)')
ylabel('Amplitude')
You can also use FFTSHIFT itself to construct the frequency vector. The frequency vector can be constructed as follows:
dftFreqVec = (0:NFFT-1)*Fs/NFFT;
shiftedFreqVec = fftshift(dftFreqVec);
Best Answer