filtering sin signal with fft

4 views (last 30 days)
geem
geem on 26 Jun 2013
Hi all, Ihave a problam about filtering a sin signal ı must filter low frequencies(under 52 hz) and do this with fft. So ı try to do it with a fir low pass filter then fftfilt command. Did anyone suggest something else or commeny on it.

Answers (1)

Image Analyst
Image Analyst on 26 Jun 2013
What frequency is your sine signal? Why do you think there are any frequencies other than that one? Anyway, to filter, you call fft, zero out low frequencies, which will be at the low end of the array, and the high end, then inverse transform. Or you can use fftshift and zero out the middle of the fft array.
  3 Comments
Image Analyst
Image Analyst on 26 Jun 2013
OK, did you try what I said? Did you see 4 spikes in your FFT spectrum?
geem
geem on 26 Jun 2013
Edited: geem on 26 Jun 2013
if i'm wrong please correct me first i use fft then fftshift but i saw only one 2 spike
Fs=25600;
T=1/Fs;
% Length of signal
L=5120
t = (0:L-1)*T; % Time vector
fo=50; f1=52;
y = 10*sin(2*pi*fo*t) + 5*sin(2*pi*f1*t);
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1);
% % Plot single-sided amplitude spectrum.
figure(1)
stem(f,2*abs(Y(1:NFFT/2+1)))
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')
filt_Y2=fftshift(Y);
figure(2)
stem(f,2*abs(filt_Y2(1:NFFT/2+1)),'y');

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!