Reputation: 1
I need to bandpass filter vibration data.
I have a signal sampled at 48kHz. I need to extract 40 signals from it. Each of the 40 signals is a band of interest, for example, 20 to 600 Hz or 600 to 1200 Hz and so on.
I've tried using the command bandpass()
but is too slow for my needs.
I've tried to use fftfilt()
but it gives poor results in comparison (amplitude in the filtered waveform is zero! even if the band in the spectrum is occupied by signal)
Could someone help me to find a fast solution for filtering this kind of data? (accH
is the signal)
This is the code for the 2 kinds of filtering:
accH=randn(48000*5,1);% simulating vibration data using randn.
%% bandpass filtering (slow)
LB=0:600:24000-600;LB(1)=20;
UB=600:600:24000;UB(end)=24000-20;
A1=zeros(length(accH),length(LB));
for k=1:length(UB)
A1(:,k)=bandpass(accH,[LB(k) UB(k)],Fs);
end
%% fftfilt filtering (not working)
A=zeros(length(accH),length(LB));
for j=1:length(UB)
bpfilt = designfilt('bandpassfir', ...
'FilterOrder',20,'CutoffFrequency1',LB(k), ...
'CutoffFrequency2',UB(k),'SampleRate',Fs);
`A(:,k)=fftfilt(bpfilt,accH);
end
bandpass vs fftfilt.
I have attached an image of the results of the filters. In black there is the waveform of the band from 6000 to 6600 Hz. In red, there is the waveform of the fftfilt()
.
Clearly, there are some problems....
I need some suggestions for fast filtering (I do not need a steep filter)
Upvotes: 0
Views: 39
Reputation: 52
You have a typo in the second section. Correct the loop variable as k
instead of j
and it works.
%% fftfilt filtering (not working)
A=zeros(length(accH),length(LB));
for k=1:length(UB)
bpfilt = designfilt('bandpassfir', ...
'FilterOrder',20,'CutoffFrequency1',LB(k), ...
'CutoffFrequency2',UB(k),'SampleRate',Fs);
`A(:,k)=fftfilt(bpfilt,accH);
end
Upvotes: 0