How to build a bandpass filter in Matlab with the butter function?

泄露秘密 提交于 2020-04-30 06:28:38

问题


I am trying to extract the mu suppression values from my EEG dataset, which doesn't allow using EEGLab. I did most of the steps, but I need to add a bandpass filter and I am not sure how.

The frequency band I would need is 8-13, my sampling rate is 1000 and I was told I would need an order of between 8 and 10.

The MATLAB documentations lists this example:

[A,B,C,D] = butter(10,[500 560]/750); 
d = designfilt('bandpassiir','FilterOrder',20, ... 'HalfPowerFrequency1',500,'HalfPowerFrequency2',560, ... 'SampleRate',1500);

However, I am not sure, what parameters I need to use for my case except for sampling rate and filter order. Also, it is not clear to me what is [A,B,C,D]. I would appreciate any input.


回答1:


I usually go over the individual functions themselves -- you did a little mix-up. The first input to butter is already the filter order (so you have specified order 10 and tried to specify order 20 in the desginfilt function...). For the Butterworth-filter, MATLAB recommends to use the zero-pole-gain formulation rather than the standard a-b coefficients. Here is an example:

f_low = 100; % Hz
f_high = 500; % Hz
f_sampling = 10e3; % 10kHz

assert(f_low < f_high)


f_nrm_low   = f_low /(f_sampling/2);
f_nrm_high  = f_heigh /(f_sampling/2);

% determine filter coefficients:
[z,p,k] = butter(4,[f_nrm_low f_nrm_high],'bandpass');
% convert to zero-pole-gain filter parameter (recommended)
sos = zp2sos(z,p,k); 
% apply filter
sig_flt = sosfilt(sos,sig);

I have filled with with standard values from my field of working. 4th order is the overwhelming standard here. In your case, you would simply go with

f_low = 200; % Hz
f_high = 213; % Hz
f_sampling = 1000; % 1kHz

f_nrm_low   = f_low /(f_sampling/2);
f_nrm_high  = f_heigh /(f_sampling/2);

% determine filter coefficients:
[z,p,k] = butter(15,[f_nrm_low f_nrm_high],'bandpass');

PS: the type 'bandpath' is not required as the function is aware of this if you specify an array as input ;)



来源:https://stackoverflow.com/questions/61369933/how-to-build-a-bandpass-filter-in-matlab-with-the-butter-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!