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.

답변 (1개)

Star Strider
Star Strider 2018년 11월 7일

0 개 추천

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

Ricardo Whitaker
Ricardo Whitaker 2018년 11월 10일
Thanks for the answer. I keep getting an error saying that my cutoff freq should be between 0 and 1
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.

댓글을 달려면 로그인하십시오.

카테고리

질문:

2018년 11월 7일

댓글:

2018년 11월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by