-1
我有一个信号,我想提取频率介于14赫兹至14.4赫兹之间。我使用butterworth这样的带通滤波器,但答案是不可接受的。现在我想知道如何使用FFT滤波器来获得我的频率。 我写这篇文章的代码在MATLAB:信号的FFT滤波
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]);
和我上载的信号文件在此链接: http://wikisend.com/download/428686/SignalData2.mat
但滤波器信号是NaN。 有没有解决这个问题的想法? 结果图像: http://i58.tinypic.com/11ukn61.jpg
正确,'hsuup'为中心值0,导致'0/0' *错误*。 – rst
谢谢。回复。我怎样才能使用我的窗口。我的窗户是海明。 –