butterworth band pass filter

10 views (last 30 days)
Udit Narayan
Udit Narayan on 13 May 2020
Commented: Star Strider on 14 May 2020
can you tell me how to apply a butterworth bandwith filter which only allows frequency of 0.5-25hz where sampling frequency is 1000 samples per second to a signal .

Answers (1)

Star Strider
Star Strider on 13 May 2020
Try this:
Fs = 1000; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency (Hz)
Wp = [1 25]/Fn; % Normalised Passband (Passband = 1 Hz To 25 Hz)
Ws = [0.5 35]/Fn; % Normalised Stopband (Passband = ½ Hz To 35 Hz)
Rp = 1; % Passband Ripple/Attenuation
Rs = 60; % Stopband Ripple/Attenuation
[n,Wn] = buttord(Wp, Ws, Rp, Rs); % Calculate Filter Optimum Order
[z,p,k] = butter(n, Wn,'bandpass'); % Create Filter
[sos,g] = zp2sos(z,p,k); % Second-Order-Section For Stability
figure
freqz(sos, 2^26, Fs)
That is a (reasonably) complete way to design filters using the individual function syntax.
  4 Comments
Udit Narayan
Udit Narayan on 14 May 2020
Edited: Udit Narayan on 14 May 2020
should i directly use [sos,g] in place of (b,a )in filtfilt( b , a , x ) or there is another way
??
Star Strider
Star Strider on 14 May 2020
Yes.
Use ‘sos’ and ‘g’ as:
y_filt = filtfilt(sos, g, y);
.

Sign in to comment.

Products


Release

R2015a

Community Treasure Hunt

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

Start Hunting!