필터 지우기
필터 지우기

butterworth filter cutoff frequency calculation

조회 수: 15 (최근 30일)
masih
masih 2017년 6월 15일
편집: Daniel M 2019년 10월 29일
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.

채택된 답변

Star Strider
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
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
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 CenterFile Exchange에서 Digital and Analog Filters에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by