FFT Filtering of signal

Hi there. I have a signal and I want extract some frequencies like 14 hz. I use some band pass filter like butterworth but answer is not acceptable. And now I want to know how can I use FFT Filter to get my frequency. Best regards.

10 Comments

What does not work about your filter?
Post your code, as well as sampling frequency and if possible, attach your signal file or a sample of it.
Ali Izadi
Ali Izadi on 7 Jun 2015
Edited: Ali Izadi on 7 Jun 2015
Xfft=fft(data);
FerequencyIndex = round(13*numberofsample/fs)+1;
Zdata=zeros(1,numberof sample);
Zdata(FerequencyIndex) = xfft(FerequencyIndex);
Filterdata=real(iffy(Zdata));
13 is my desire frequency that I want to extract form my signal.
Is it true? For fft filtering?
FerequencyIndexx is different than FerequencyIndex so that should cause an error.
Ali Izadi
Ali Izadi on 7 Jun 2015
Edited: Ali Izadi on 7 Jun 2015
Sorry. This is prototype of my code. I handle syntax error in my program. In other hand is my algorithm right for filtering by fft?
This will be another error "numberof sample". Do you know there is a way you can copy your code to the clipboard and paste it back here so that you do not need to re-type everything? In Windows you can use Ctrl-c and Ctrl-v.
And what do you mean "extract form"? Do you just want to throw away everything in your data except a perfect sine wave at a frequency of 13? So your output will look like a perfect sine wave?
Ali Izadi
Ali Izadi on 8 Jun 2015
Edited: Ali Izadi on 8 Jun 2015
My fft filter code :
clc;
clear all;
load('SignalData2');
[n,c] = size(mydata2);
mydata1 = mydata2(1:n,1);
% my sample rate is 39500 or datalenth/4
fs = n/4;      % Sampling rate [Hz]
Ts = 1/fs;       % Sampling period [s]
fNy = fs / 2;    % Nyquist frequency [Hz]
noSamples = n;   % Number of samples
f = 0 : fs/noSamples : fs - fs/noSamples; % Frequency vector
figure;
subplot(2,2,1);
plot(mydata1);
x_fft = abs(fft(mydata1));
subplot(2,2,2);
plot(f,x_fft);
xlim([1 150]);
bw=0.2;      %Bandwisth
fc=pi*14.2;     %Center Frequency
L = n;       % sample number;
%Compute Hamming window
for nn=1:L
    hamm(nn)=(0.54-0.46*cos(2*pi*nn/L));
end
%Compute Filter
hsuup=(-(L-1)/2:(L-1)/2);
hideal1=hamm.*(2*(fc+bw)*(sin(2*(fc+bw)*hsuup/fs)./(2*(2*fc+bw)*hsuup/fs)));
hideal2=hamm.*(2*(fc-bw)*(sin(2*(fc-bw)*hsuup/fs)./(2*(2*fc+bw)*hsuup/fs)));
h_bpf=(hideal1-hideal2);
comp_sig_fft=fft(mydata1)'/L;
h_bpf_fft=fft(h_bpf) /L;
s100_fft=comp_sig_fft.*h_bpf_fft;
band_passed_signal=real(ifft(s100_fft));
subplot(2,2,3);
plot(band_passed_signal);
%
x_fft = abs(fft(band_passed_signal));
subplot(2,2,4);
plot(f,x_fft);
xlim([1 150]);
   
is your problem solved now?!
No. My problem exists yet. If you run code, fft filter result is NaN. I want filter my signal to get 14 hz - 14.4 hz signal.
I do not know why my code doesn't work properly. I design a band pass filter by hamming windows and fft algorithm to extract 14hz to 14.4hz signal. Is there any idea? Is there any mistake in my code?

Sign in to comment.

Answers (0)

Tags

Asked:

on 7 Jun 2015

Commented:

on 8 Jun 2015

Community Treasure Hunt

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

Start Hunting!