## Band Pass Filter Design

### Ricardo Whitaker (view profile)

on 7 Nov 2018
Latest activity Commented on by Star Strider

### Star Strider (view profile)

on 10 Nov 2018
Hello everyone, I am trying to build a bandpass filter in matlab for an EMG signal. I know I want the band to be between 10 and 500 Hz. However, using fdesign.bandpass function it gives me many parameters ('Fst1,Fp1,Fp2,Fst2,Ast1,Ap,Ast2'). Which value should I use for each parameter? I appreciate the help.

### Star Strider (view profile)

on 7 Nov 2018

If you have R2018a or later, you can use the bandpass (link) function.
Otherwise, try this:
t = your_time_vector;
EMG = your_signal;
Fs = ...; % Sampling Frequency (Hz)
Fn = Fs/2; % Nyquist Frequency (Hz)
Wp = [10 500]/Fn; % Passband Frequency Vector (Normalised)
Ws = [8 510]/Fn; % Stopband Frequency Vector (Normalised)
Rp = 1; % Passband Ripple (dB)
Rs = 50; % Stopband Attenuation (dB)
[n,Wp] = ellipord(Wp,Ws,Rp,Rs); % Calculate Filter Order
[z,p,k] = ellip(n,Rp,Rs,Wp,'bandpass'); % Default Here Is A Lowpass Filter
[sos,g] = zp2sos(z,p,k); % Use Second-Order-Section Implementation For Stability
EMG_filtered = filtfilt(sos,g,EMG); % Filter Signal (Here: ‘EMG’)
figure
freqz(sos, 2^14, Fs) % Bode Plot Of Filter
% set(subplot(2,1,1), 'XLim',[0 Fn]) % Optional, Change Limits As Necessary
% set(subplot(2,1,2), 'XLim',[0 Fn]) % Optional, Change Limits As Necessary
figure
plot(t, EMG_filtered)
grid
Note that your sampling frequency ‘Fs’ must be greater than 1000 Hz for this filter to work. The upper limit of your filter passband must be less than the Nyquist frequency.

Ricardo Whitaker

### Ricardo Whitaker (view profile)

on 10 Nov 2018
Thanks for the answer. I keep getting an error saying that my cutoff freq should be between 0 and 1
Star Strider

### Star Strider (view profile)

on 10 Nov 2018
My pleasure.
First: there was a slight error in the passband and stopband frequency vectors.