I have a very simple code for ploting frequency spectrum of a signal in MATLAB. My center frequency is at 5e6 but I see a much higher peak at zero frequency despite the fact that I remove DC component from my signal. Why this peak happens?
Fs = 40e6 ;
[freq,z_freq] = freq_spectrum(RF_ch,Fs) ;
figure;
plot(freq,abs(z_freq));xlabel('Frequency');title('Frequency Spectrum')
function [f,z] = freq_spectrum(x,Fs)
N = size(x,1) ; %size(x)
f = -Fs/2:Fs/(N-1):Fs/2;
x = detrend(x) ; % or %x = x - mean(x);
z = fftshift(fft(x))./numel(x) ;
end