필터 지우기
필터 지우기

Wrong amplitude values after the FFT

조회 수: 3 (최근 30일)
engineer bsc
engineer bsc 2012년 6월 11일
Hi all, At the plot of the code that written below, i should see amplitude between values of 75 to 200 uV but there is something strange in my plot, can you help me and advise, what wrong with my code and how can i correct that ?
Thank you all
Here is the code :
clear all;
close all;
Fs = 200
t= 0:1/Fs:180
y_in=zeros (1, length(t));
for i = 1:18
F = randi ([4 7], 1);% frequency
A = randi ([75 200],1);% amplitude A=75~200 uV.
y_tmp =A*sin (2*pi*F*t);
y_in=y_in+ y_tmp;
end;
L=length (y_in);
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y_new = fft(y_in,NFFT)/L;
f_new = Fs/2*linspace(0,1,NFFT/2+1);
figure(1)
plot(f_new,2*abs(Y_new(1:NFFT/2+1))) ;
title('Single-Sided Amplitude Spectrum of y_in(t)')
xlabel('Frequency (Hz)')
ylabel('|y_in(f)|')

채택된 답변

Wayne King
Wayne King 2012년 6월 12일
The main issue you have is that you are only randomly sampling from a small set of frequencies and you are doing that 18 times, then you don't vary the phase at all. Therefore, you're going to generate the same frequency more than once. You're adding sine waves at the same frequency and phase with different amplitudes. Therefore the resulting amplitude is going to be the sum of the individual amplitudes.
I'll verify this for a frequency of 4 Hz.
Fs = 200;
t= 0:1/Fs:180-1/Fs;
y_in=zeros (1, length(t));
for i = 1:18
F = randi ([4 7], 1);% frequency
freqv(i) = F;
A = randi ([75 200],1);% amplitude A=75~200 uV.
amp(i) = A;
y_tmp =A*sin (2*pi*F*t);
y_in=y_in+ y_tmp;
end;
L=length(y_in);
Y_new = fft(y_in);
Y_new = Y_new(1:length(y_in)/2+1)/L;
Y_new(2:end-1) = 2*Y_new(2:end-1);
f_new = Fs/2*linspace(0,1,length(y_in)/2+1);
plot(f_new,abs(Y_new));
title('Single-Sided Amplitude Spectrum of y_in(t)')
xlabel('Frequency (Hz)')
ylabel('|y_in(f)|')
Note that if we find the number of times, 4 Hz is added and sum the amplitudes of those components, you get your answer.
indices = find(freqv == 4);
amp4 = sum(amp(indices));
You see that amp4 is the amplitude of your component at 4 Hz in the plot.

추가 답변 (1개)

engineer bsc
engineer bsc 2012년 6월 12일
guys, please,someone ?
it is really important to me.
thanks

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by