How to Design a Band-Pass Filter

100 ビュー (過去 30 日間)
Ricardo Whitaker
Ricardo Whitaker 2018 年 11 月 13 日
コメント済み: Star Strider 2020 年 7 月 3 日
Hello everyone,
I've been having issues to create a band pass filter to treat EMG signals. I want to create a band pass filter of bandwith 85 (10-95) and my sampling rate is 200 Hz. After that, I would like to plot the frequency spectrum of the signal to verify that I filtered it correctly. Could someone help me with that? I appreciate any kind of help.

回答 (2 件)

Mark Sherstan
Mark Sherstan 2018 年 11 月 13 日
Check out the bandpass filter from the signal processing toolbox located here. I would imagine your function would look something like this (a similar question was asked here):
% signalEMG = Your data
filteredEMG = bandpass(signalEMG,[10 95],200)
Plot the results using a FFT (you may need to tweak a few of the values such as L depending on your data):
Fs = 200;
T = 1/Fs;
L = 1500;
t = (0:L-1)*T;
Y = fft(filteredEMG);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
plot(f,P1)
title('Single-Sided Amplitude Spectrum of X(t)')
xlabel('f (Hz)')
ylabel('|P1(f)|')

Star Strider
Star Strider 2018 年 11 月 14 日
Try this:
EMG = rand(1,1E+4); % EMG Signal
N = length(EMG);
Fs = 200; % Sampling Frequency (Hz)
t = linspace(0, N, N)/Fs; % Time Vector (If One Has Not Been Supplied With Your EEG Record)
Fn = Fs/2; % Nyquist Frequency (Hz)
Wp = [10 95]/Fn; % Passband Frequency Vector (Normalised)
Ws = [ 9 96]/Fn; % Stopband Frequency Vector (Normalised)
% Wp = 3.5/Fn;
% Ws = 2.5/Fn;
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: ‘x’)
figure
freqz(sos, 2^14, Fs) % Bode Plot Of Filter
% set(subplot(2,1,1), 'XLim',[0 15]) % Optional, Change Limits As Necessary
% set(subplot(2,1,2), 'XLim',[0 15]) % Optional, Change Limits As Necessary% x = rand(1,1E+4);
nfft = 2^nextpow2(N);
FEMG_filtered = fft(EMG_filtered)/N;
Fv = linspace(0, 1, fix(N/2)+1)*Fn; % Frequency Vector
Iv = 1:length(Fv); % Index Vector
figure
plot(Fv, abs(FEMG_filtered(Iv))*2)
grid
  2 件のコメント
Ben
Ben 2020 年 7 月 3 日
Star Strider, the output signal here is FEMG_filtered or EMG_Filtered? FEMG is a complex signal.Gracias, Ben
Star Strider
Star Strider 2020 年 7 月 3 日
Ben — The filtered output is ‘EMG_filtered’. The Fourier transform of it is ‘FEMG_filtered’. The purpose of that is to demonstrate the effect of the filtering.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpectral Measurements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by