Why fft spectrum amplitude of signal changes?
이전 댓글 표시
Hi,anyone can help me about the fft function?
I use fft function to get the spectrum of my signal, the amplitude of the spectrum is not same with the original signal, I have to scale it with a certain factor to get the right signal. Anyone could tell me the reason?
The code is
fs0= 500; %%signal original frequency
ts0=1/fs0;
T=1; %%time length
t=0:ts0:T; %%time vector
fsn= 50; %%new sampling frequency
tsn=1/fsn;
B=15; %%signal bandwidth
%%%%%%%%%%%%%%%%%%%%information %%%%%%%%%%%%%%%%%%%%%%%
m=sin(2*pi*t)+cos(2*pi*3*t)-sin(2*pi*5*t);
LoS=length(m); %%length of message
%%%%%%%%%%%%%%%%%%%%sampling %%%%%%%%%%%%%%%%%%%%%%%%%%
N=round(fs0/fsn); %%sample factor
m_s=downsample(m,N); %%sampling output
m_s=upsample(m_s,N); %%make the sampled output have the suitable length
%%%%%%%%%%%%%%%%%%%%%%%%%reconstruct signal %%%%%%%%%%%%%%%%%%%%%%%%
%Lf=2^ceil(log2(LoS)+1); %%Spectrum deviation
Lf=2^nextpow2(LoS);
f=linspace(-fs0/2,fs0/2,Lf); %%frequency vector
M=fftshift((fft(m,Lf))); %%spectrum of signal
M_S= fftshift((fft(m_s,Lf))); %%sampled signal in frequency domain
figure(1)
subplot(311);
plot(t,m,'k');
hold on;
plot(t,m_s(1:LoS),'b');
hold off;
title('signal m and ite uniform samples');
xlabel('time(sec)');
ylabel('Amplitude');
subplot(312);
plot(f,abs(M));
title('Spectrum of signal m');
xlabel('Frequency(Hz)');
subplot(313);
plot(f,abs(M_S));
title('spectrum of sampled signal');
xlabel('Frequency(Hz)');
The output diagram is

You could see the amplitude is N times smller than the original signal, why does this happen? and why it is N?
One more question, why the spectrum of sampled signal looks lost energy? If I increase the number of DFT points to 1024, the result will be better, nearly all frequency components are present, why? well,the amplitude remains same.
답변 (2개)
Honglei Chen
2014년 7월 7일
1 개 추천
I'm not quite sure what you try to achieve here, but you use downsample then upsample. Note that upsample merely insert N-1 zeros in between the samples, so your signal contains only 1/Nth of samples compare to the original, that's why your amplitude is only 1/Nth.
댓글 수: 2
Amy Feng
2014년 7월 7일
Honglei Chen
2014년 7월 8일
편집: Honglei Chen
2014년 7월 8일
Because your signal only has certain frequency components and the way you do FFT you don't sample right at those frequencies. Using more points simply gets you closer to those frequency points so the result is better. But for your case, if you make your Lf the same as LoS, the result will be better too.
BTW, you have a mistake in your frequency vector, it should be
f=-fs0/2:fs0/Lf:fs0/2-fs0/Lf;
not
f=linspace(-fs0/2,fs0/2,Lf);
HTH
Image Analyst
2014년 7월 7일
0 개 추천
Why do you think the amplitude in the frequency domain should be the same as the amplitude in the spatial or time domain?
카테고리
도움말 센터 및 File Exchange에서 Spectral Measurements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!