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.

Respuestas (2)

Honglei Chen
Honglei Chen el 7 de Jul. de 2014

1 voto

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 comentarios

Amy Feng
Amy Feng el 7 de Jul. de 2014
Oh,Thank you very much. You have answered my major question. Could you tell me why the spectrum lost some energy? I mean for example at 100Hz or -100Hz, the spectrum shape should be same with the spectrum at 0 Hz, but in the figure, it is obviously distorted. Why? If I use more DFT points for fft function, then the result will be better.
Honglei Chen
Honglei Chen el 8 de Jul. de 2014
Editada: Honglei Chen el 8 de Jul. de 2014
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

Iniciar sesión para comentar.

Image Analyst
Image Analyst el 7 de Jul. de 2014

0 votos

Why do you think the amplitude in the frequency domain should be the same as the amplitude in the spatial or time domain?

1 comentario

Amy Feng
Amy Feng el 8 de Jul. de 2014
Do you see the second and third diagrams in the above figure? I think they should have same amplitude. They are all in the frequency domain and the last diagram contains same signal with the third diagram but repeats every 50Hz.

Iniciar sesión para comentar.

Preguntada:

el 7 de Jul. de 2014

Editada:

el 8 de Jul. de 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by