Band Pass Filter Design

19 visualizaciones (últimos 30 días)
Ricardo Whitaker
Ricardo Whitaker el 7 de Nov. de 2018
Comentada: Star Strider el 10 de Nov. de 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.

Respuestas (1)

Star Strider
Star Strider el 7 de Nov. de 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.
  2 comentarios
Ricardo Whitaker
Ricardo Whitaker el 10 de Nov. de 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 el 10 de Nov. de 2018
My pleasure.
First: there was a slight error in the passband and stopband frequency vectors.
Use these instead:
Wp = [10 495]/Fn; % Passband Frequency Vector (Normalised)
Ws = [ 8 498]/Fn; % Stopband Frequency Vector (Normalised)
Second: ‘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.’
Third: If you want a highpass filter instead of a bandpass filter with a sampling frequency of 1000 Hz, change these lines to:
Wp = 10/Fn; % Passband Frequency Vector (Normalised)
Ws = 8/Fn; % Stopband Frequency Vector (Normalised)
. . .
[z,p,k] = ellip(n,Rp,Rs,Wp,'high'); % Default Here Is A Lowpass Filter
If your sampling frequency is 1000 Hz, and you want to pass all frequencies above 10 Hz, that will design a sufficient filter.

Iniciar sesión para comentar.

Categorías

Más información sobre Spectral Measurements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by