Proper (butterworth) bandpass filter
이전 댓글 표시
Hey guys! I'm fairly new with signal processing in matlab. I have some labdata that are corrupted by noise. I would like to make a (butterworth) bandpass filter between approx. 0.5 kHz and 1.5 kHz. I have tried a lot of different approaches from browsing the net. My latest attempt looks like this:
%-------- loading time series-----------
load('filtest1000hz.txt');
time=filtest1000hz(:,1); %time
volin=filtest1000hz(:,2); %volt input [V]
volout=filtest1000hz(:,3); %volt output [mV]
%-------- loading spectrum -----------------
load('filtestspectrum1000hz.txt');
freq=filtestspectrum1000hz(:,1)*10^3; %frequency in kHz
powin=filtestspectrum1000hz(:,2); %power input
powout=filtestspectrum1000hz(:,3); %power output
fs=10*10^(3); %sample rate in kHz
inputsig=powin; %input signal
order=2; %order of filter
fcutlow=0.1; %low cut frequency in kHz
fcuthigh=1.7; %high cut frequency in kHz
[b,a]=butter(order,[fcutlow,fcuthigh]/(fs/2),'bandpass');
filtsig=filter(b,a,inputsig); %filtered signal
This is the output i get (3rd subplot) when i plot the "filtsig" vs. the frequency (freq). You can see the original spectrum (intended) but the filtered spectrum does not even show up:

and this is the format of my data from the time series and the spectrum (input channel and output channel):

I have spend a lot of hours trying to figure out how to do the bandpass properly. Can some of you figure out what is wrong?
Kind regards
답변 (1개)
Jordan Ross
2017년 1월 24일
Hello Emil,
I believe the issue is that when you specify the passband frequencies for the filter you are specifying it to be between 0.1 and 1.7Hz instead of the KHz that you are expecting. Therefore, what you need is the following:
fcutlow=100; %low cut frequency in Hz
fcuthigh=1700; %high cut frequency in Hz
[b,a]=butter(order,[fcutlow,fcuthigh]/(fs/2),'bandpass');
Also, I would recommend checking out the Filter Designer tool. In the tool you can export the designed filter to a .m file. http://www.mathworks.com/help/signal/ug/getting-started-with-filter-designer.html
댓글 수: 3
Andi Ferdiawan
2019년 12월 17일
what function for order ?
Biswajit Ojha
2020년 3월 11일
For the order, you have to choose numeric values , e.g. 3 or 4 or 5 ..
Star Strider
2020년 3월 11일
카테고리
도움말 센터 및 File Exchange에서 Butterworth에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!