How can I set a frequency range for a butterworth filter?

10 次查看(过去 30 天)
I want to use a bandpass butterworth filter that only takes in frequencies between 1-25 Hz. How would I go about doing that? The butter function only accepts values in (0,1). Thank you so much!

采纳的回答

Star Strider
Star Strider 2015-6-1
You have to normalise your frequencies in terms of the Nyquist frequency (one-half the sampling frequency). So if you have a sampling frequency of, for instance, 100 Hz, you might design your filter as:
Fs = 100; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency (Hz)
Wp = [1 25]/Fn; % Filter Passband (Normalised)
Ws = Wp.*[.75 1/.75]; % Filter Stopband (Normalised)
Rp = 1; % Passband Ripple (dB)
Rs = 50; % Stopband Ripple (dB)
[n,Wn] = buttord(Wp, Ws, Rp, Rs);
[b,a] = butter(n, Wn);
[sos,g] = tf2sos(b,a);
then examine it for stability:
figure(1)
freqz(sos, 1024, Fs)
If you are satisfied with the design as plotted with freqz, use it with filtfilt to filter your signal. If not, adjust the stopband and ripple until you have a stable filter that performs as you want it to. Filter design sometimes requires a few adjustments to get it the way you want it.
  5 个评论
Star Strider
Star Strider 2015-6-2
The stopband limits define the ‘steepness’ of the rolloff of the passband, and therefore the order of the filter. As with everything else in digital filter design, they are defined according to the characteristics of your signal. I have found that the limits of [0.75 1/0.75] times the passband for a bandpass filter work well in practice and usually produce a stable filter with good characteristics. If the filter (always use the second-order-section implementation for maximum stability) is not stable, I change the passband and stopband limits until it is. The stopband limits are yours to decide, so you have to choose them so you have a stable filter that does what you want.
If you’re going to be working with digital filters in your research, I encourage you to take a course in digital signal processing. There is much more to it than in my brief comments here.
My pleasure!
I apologise for the delay — life intrudes.
Darsana P M
Darsana P M 2017-3-16
In the above question,if suppose we need to divide frequencies 1-25Hz,25-50 Hz and so on in the same graph, what should we do?

请先登录,再进行评论。

更多回答(1 个)

Rohit Kanji
Rohit Kanji 2016-8-18
If I change Fs = 100 in the above code to Fs = 400, it does not work. Why is that?

Community Treasure Hunt

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

Start Hunting!

Translated by