了解这个函数,先看看这个基础知识:【 MATLAB 】Rational Transfer Function(有理传递函数)
filter
1-D digital filter
Syntax
y = filter(b,a,x)
y = filter(b,a,x,zi)
y = filter(b,a,x,zi,dim)
[y,zf] = filter(___)
Description
使用由分子和分母系数 b 和 a 定义的有理传递函数对输入数据 x 进行滤波。y
= filter(b
,a
,x
)
If a(1)
is not equal to 1
, then filter
normalizes the filter coefficients by a(1)
. Therefore, a(1)
must be nonzero.
-
If
x
is a vector, thenfilter
returns the filtered data as a vector of the same size asx
. -
If
x
is a matrix, thenfilter
acts along the first dimension and returns the filtered data for each column. -
If
x
is a multidimensional array, thenfilter
acts along the first array dimension whose size does not equal 1.
针对这条语法举个例子:
Moving-Average Filter
移动平均滤波器是用于平滑噪声数据的常用方法。 此示例使用过滤器函数计算沿数据向量的平均值。
Create a 1-by-100 row vector of sinusoidal data that is corrupted by random noise.
t = linspace(-pi,pi,100); rng default %initialize random number generator x = sin(t) + 0.25*rand(size(t));
A moving-average filter slides a window o