butterworth filter cutoff frequency calculation
18 次查看(过去 30 天)
显示 更早的评论
Hi All, I am not a electrical engineer so my question may sound stupid. Sorry about that. I have a some noisy data and I want to filter my data using a butterworth filter of order 2. I am having trouble finding the cutoff frequency for the filter design. How do I calculate cutoff frequency? I am sampling my data every 10 seconds. Thnanks.
0 个评论
采纳的回答
Star Strider
2017-6-15
First, a Butterworth (or any) filter of order 2 is not likely to work as well as you want it to. You may find a Chebyshev Type II design more appropriate, especially with your extremely low sampling frequency.
Second, the best way to design a band-selective filter is to take the fft (link) of your signal to determine where the signal frequencies are and where the noise frequencies are. Use that information to design your filter. Note that if you have broadband noise, a frequency-selective filter will not eliminate all of the noise. You might want to eliminate baseline offset and low-frequency baseline variation as well, the reason I usually use a bandpass design.
The designfilt function can make filter design straightforward. Another acceptable way to design a Butterworth filter is this bandpass prototype:
Fs = 0.1; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency
Wp = [0.002 0.010]/Fn; % Specify Bandpass Filter
Ws = [0.001 0.015]/Fn; % Stopband (normalised)
Rp = 10; % Passband Ripple (dB)
Rs = 30; % Stopband Ripple (dB)
[n,Wn] = buttord(Wp, Ws, Rp, Rs);
[z,p,k] = butter(n,Wn); % ZPK
[SOS,G] = zp2sos(z,p,k); % Convert To SOS for Stability
figure(2)
freqz(SOS, 2^16, Fs)
To design a Chebyshev Type II filter, replace buttord with cheb2ord and butter with cheby2. The arguments are slightly different, so keep that in mind. The rest of the code does not change.
10 个评论
Star Strider
2019-10-29
@Ahmed Hassan — Post this as a new Question, and include more information.
I will delete this Comment in a few hours.
Daniel M
2019-10-29
编辑:Daniel M
2019-10-29
Hi Star Strider, I'm trying to follow along, but when I run your code, I get the following error:
Warning: Usage of DATENUM with empty date character vectors or empty strings is
not supported.
Results may change in future versions.
> In datenum (line 95)
In untitled48 (line 2)
Error using plot
Vectors must be the same length.
Error in untitled (line 4)
plot(t, d)
t is empty because datenum() failed.
It seems to be an issue with xlsread on Linux, because
whos d s
Name Size Bytes Class Attributes
d 1999x3 47976 double
s 1x3 396 cell
On Windows it works properly. So nevermind then, I'll just do it there.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Digital and Analog Filters 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!