Band-pass Butterworth filter
5 次查看(过去 30 天)
显示 更早的评论
Hello, I'm trying to make a band-pass Butterworth filter in order to filter a signal. With the help of Star Strider I already made a high-pass filter:
Fcp=1; %cutoff frequency
[z,p,k]=butter(8,Fcp/(Fsp/2),'high');
[sos,g]=zp2sos(z,p,k);
%fvtool(sos,'Analysis','freq')
deltap1filtfilt=filtfilt(sos,g,deltap_1);
I tried to make a band-pass Butterworth filter with this indications (https://it.mathworks.com/matlabcentral/answers/272316-how-to-butterworth-filter-with-bandpass-10-500-with-sampling-rate-1000) but it doesn't work. My sampling frequency is 600 Hz and I'd like to make visible only frequency contributes from 1 Hz to 50 hz. Thank u very much!
2 个评论
Jan
2017-3-1
Please post, what you have tried and explain "doesn't work" with details. Then suggestion an improvement is much easier.
采纳的回答
Star Strider
2017-3-1
There is an error in your code that prevents you from calculating the passbands and stopbands correctly.
This calculation:
Wp = [1 49]/Fsp/2;
gives you these passbands:
Wp =
0.0005 0.0245
However the passbands you want are:
Wp = [1 49]/(Fsp/2);
Wp =
0.002 0.098
Those will give you the correct result. The parentheses around ‘(Fsp/2)’ make all the difference.
If you want to design a filter with rolloffs as steep as you want, a Butterworth filter is not the best option. I would use a Chebyshev Type II design.
The Code —
Fsp = 1000; % Create Data
Fn = Fsp/2;
Wp = [1.0 49]/Fn;
Ws = [0.5 50]/Fn;
Rp=10;
Rs=30;
[n,Ws] = cheb2ord(Wp,Ws,Rp,Rs);
[z,p,k] = cheby2(n,Rs,Ws);
[sos,g] = zp2sos(z,p,k);
figure(1)
freqz(sos, 2^16, Fsp)
set(subplot(2,1,1), 'XLim',[0 100]) % ‘Zoom’ X-Axis
set(subplot(2,1,2), 'XLim',[0 100]) % ‘Zoom’ X-Axis
The passband ripple in a Chebyshev Type II filter are irrelevant, since the filter has a flat passband. Allowing them to be 10 dB allows you to design a stable filter.
2 个评论
Star Strider
2017-3-2
My pleasure.
It looks like it should work. It depends on the filter characteristic you want.
The filter I posted in my Answer is the one you originally described in your Question. A Butterworth filter cannot do that effectively.
I would compare the two filters to see which design works best in your application.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!