如何使用黄油功能在Matlab中构建带通滤波器? [英] How to build a bandpass filter in Matlab with the butter function?

查看:147
本文介绍了如何使用黄油功能在Matlab中构建带通滤波器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从我的EEG数据集中提取mu抑制值,这不允许使用EEGLab.我完成了大多数步骤,但是我需要添加一个带通滤波器,但不确定如何操作.

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.

我需要的频带是8-13,我的采样率是1000,并被告知我需要的阶数是8到10.

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.

MATLAB文档列出了以下示例:

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);

但是,我不确定,除了采样率和过滤器顺序以外,我需要为我的情况使用哪些参数.另外,我不清楚[A,B,C,D]是什么.我将不胜感激.

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.

推荐答案

我通常会仔细研究各个函数本身-您做了一些混淆. butter的第一个输入已经是过滤器顺序(因此您已指定顺序10,并尝试在desginfilt函数中指定顺序20 ...). 对于 Butterworth 滤波器,MATLAB建议使用零极点增益公式,而不是标准的a-b系数.这是一个示例:

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:不需要 type 'bandpath',因为如果您将数组指定为输入,则函数会意识到这一点;)

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

这篇关于如何使用黄油功能在Matlab中构建带通滤波器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆