发布网友 发布时间:2022-04-23 03:32
共2个回答
热心网友 时间:2023-10-13 10:14
看楼主的意思主要是想实现差分方程
先从简单的说起:
filter([1,2],1,[1,2,3,4,5])
实现 y[k]=x[k]+2*x[k-1]
y[1]=x[1]+2*0 %(x[1]之前状态都用0)
=1
y[2]=x[2]+2*x[1]=2+2*1=4
...
然后说你感兴趣的filter(b,a,x)
这里a,b都是矢量
你提到输入[zeros(1,100),ones(1,101)]
差分方程 2y[k]-y[k-1]-3y[k-2]=2x[k]-x[k-1]
往里面代
[1]之前的状态都为0
y[1]=1/2*(2*x[1])=0
y[2]=1/2*(2*x[2]-x[1]+y[1])=0
........
显示的数为差分方程的输出y
这个函数和还有其它的用法,再次我就不说了
matlab的帮助中说的比较详细,你可以自己看一下
热心网友 时间:2023-10-13 10:15
Y = FILTER(B,A,X) filters the data in vector X with the
filter described by vectors A and B to create the filtered
data Y. The filter is a "Direct Form II Transposed"
implementation of the standard difference equation:
a(1)*y(n) = b(1)*x(n) + b(2)*x(n-1) + ... + b(nb+1)*x(n-nb)
- a(2)*y(n-1) - ... - a(na+1)*y(n-na)
If a(1) is not equal to 1, FILTER normalizes the filter
coefficients by a(1).
FILTER always operates along the first non-singleton dimension,
namely dimension 1 for column vectors and non-trivial matrices,
and dimension 2 for row vectors.
[Y,Zf] = FILTER(B,A,X,Zi) gives access to initial and final
conditions, Zi and Zf, of the delays. Zi is a vector of length
MAX(LENGTH(A),LENGTH(B))-1, or an array with the leading dimension
of size MAX(LENGTH(A),LENGTH(B))-1 and with remaining dimensions
matching those of X.
FILTER(B,A,X,[],DIM) or FILTER(B,A,X,Zi,DIM) operates along the
dimension DIM.
参考资料:matlab help