简体   繁体   English

比较过滤后的数据:matlab 带通 function 与滤波器 function

[英]comparing filtered data: matlab bandpass function vs filter function

I'm trying to breakdown how bandpass function makes the filtering and stumped upon this line (after the filter is created).我试图分解带通 function 如何进行过滤并在这条线上遇到困难(在创建过滤器之后)。

y = signal.internal.filteringfcns.filterData(x,opts);

x is the data and opts has the filter structure. x 是数据,opts 具有过滤器结构。 I've been looking around and haven't been able to find anything about signal.internal.filteringfcns.filterData function.我一直在环顾四周,找不到任何关于signal.internal.filteringfcns.filterData function 的信息。 I compared that output with filter(opts.FilterObject,x) and they are not the same.我将 output 与filter(opts.FilterObject,x)进行了比较,它们并不相同。

Next is a minimal working example ( data2.txt ).接下来是一个最小的工作示例( data2.txt )。

load('data2.txt')

srate=64;
freqrange=[0.4 3.5];

var{1}=freqrange;
var{2}=srate;

m=numel(data2);
x=data2;
R=0.1;%10% of signal
Nr=50;
NR=min(round(m*R),Nr);%At most 50 points
x1=2*x(1)-flipud(x(2:NR+1));%maintain continuity in level and slope
x2=2*x(end)-flipud(x(end-NR:end-1));
x=[x1;x;x2];

opts=signal.internal.filteringfcns.parseAndValidateInputs(x,'bandpass',var);
opts = designFilter(opts);

xx = signal.internal.filteringfcns.filterData(x,opts);
x_fil=xx(NR+1:end-NR);

xx = filter(opts.FilterObject,x);
x_fil2=xx(NR+1:end-NR);

plot([data x_fil x_fil2])
legend('raw','filterData','filter')

Here is the plot:这是 plot:

数据

And here are the psd plot of both filtered signal (filtData first).这是两个滤波信号的psd plot(首先是filtData)。

过滤数据 筛选

So, any help on this ...filtData function or I doing something wrong in my analysis?那么,对此...filtData function 有任何帮助还是我在分析中做错了什么?

Hi again:) If you type edit signal.internal.filteringfcns.filterData , you can even look at what is inside this filterData function.再次嗨 :) 如果您键入edit signal.internal.filteringfcns.filterData ,您甚至可以查看此filterData function 内部的内容。 You will see that this function (depending on the options opts ) will either,你会看到这个 function (取决于选项opts )要么,

  • right zero pad the signal with N/2 zeros and call filter右零用N/2零填充信号并调用filter
  • call filtfilt with the signal用信号调用filtfilt

This is also described in the docs of bandpass .这也在bandpass的文档中有所描述。 So probably this zero padding explains why your output of filter(opts.FilterObject,x) is different.所以这个零填充可能解释了为什么你的 output 的filter(opts.FilterObject,x)是不同的。

You cannot find this function described in the documentation of Matlab since it is part of the internal functions of the signal processing toolbox.您无法在 Matlab 的文档中找到此 function,因为它是信号处理工具箱内部功能的一部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM