Clear Filters
Clear Filters

butterworth filter cutoff frequency calculation

15 views (last 30 days)
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.

Accepted Answer

Star Strider
Star Strider on 15 Jun 2017
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 Comments
Star Strider
Star Strider on 29 Oct 2019
@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 on 29 Oct 2019
Edited: Daniel M on 29 Oct 2019
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.

Sign in to comment.

More Answers (0)

Categories

Find more on Digital and Analog Filters in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!