本文介绍了MATLAB的filtfilt()算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图重现一个漫长的一段MATLAB code。在另一种语言已经没有内置的无相位滤波器等效 filtfilt()。我试图重新投功能的简单过滤(或卷积)操作,所以我可以很容易地重现条款。据我所知,这种滤波操作相当于向前过滤,随后通过逆过滤,但我看到在数据的边缘小的差异。具体做法是:

I'm trying to reproduce a lengthy piece of MATLAB code in another language which has no built-in equivalent of the phaseless filter, filtfilt(). I'm trying to re-cast the function in terms of simple filtering (or convolution) operations so I can easily reproduce it.I understand that this filtering operation is equivalent to forward filtering, followed by reverse filtering, but I'm seeing small differences at the edges of the data. Specifically:

data = [1 1 1 2 2 3 5 7 1 1 1 1 1];
ker = [2 1 1];

a = filtfilt(ker,1,data)

b = fliplr( filter( ker, 1, fliplr( filter(ker, 1, data) ) ) )

% a =
%
%   16   18   21   29   39   57   66   68   42   28   16   16   16
%
% b =
%
%   11   16   21   29   39   57   66   68   42   28   16   12    8

我试图用0填充的数据在一个或两个目的,一个滤波操作的一个或两个之前。我想我可能失去了一些东西很明显,但无法发现它。

I've tried padding the data with zeros at one or both ends, before one or both of the filtering operations. I think I'm likely missing something obvious, but can't spot it.

推荐答案

在filtfilt算法相匹配的过滤器的初始条件,尽量减少开始和结束瞬变(从 DOC filtfilt )。如果你键入编辑filtfilt 你可以看到code - 有一个函数 getCoeffsAndInitialConditions(B,A,NPTS),将为您展现这个细节。

The filtfilt algorithm matches the initial conditions on the filter to minimise start and end transients (from the doc filtfilt). If you type edit filtfilt you can see the code - there is a function getCoeffsAndInitialConditions(b,a,Npts) that will show you the details of this.

这篇关于MATLAB的filtfilt()算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-16 06:26