Digital Signal Processing Reference
In-Depth Information
The MATLAB function filter(), developed using a direct-form II realization (which will be discussed
in a later section), can be used to operate digital filtering, and the syntax is
Zi [ filtic(B, A, Yi, Xi)
y [ filter(B, A, x, Zi)
where B and A are vectors for the coefficients b j and a j whose formats are
A ¼½ 1
a 1
a 2
/ a N
and
B ¼½b 0
b 1
b 2
/ b M
and x and y are the input data vector and output data vector, respectively.
Note that the filter function filtic() is a MATLAB function which is used to obtain initial states from
initial conditions in the difference equation. The initial states are required by the MATLAB filter
function filter() since it is implemented in a direct-form II. Hence, Z i contains initial states required for
operating MATLAB function filter(), that is,
Z i ¼½wð 1 Þ wð 2 Þ /
which can be recovered by another MATLAB function filtic(). X i and Y i are initial conditions with the
length of the greater of M or N , given by
X i ¼½xð 1 Þ xð 2 Þ /
and
Y i ¼½yð 1 Þ yð 2 Þ /
For zero initial conditions in particular, the syntax is reduced to
y [ filter(B, A, x)
Let us verify the filter operation results in Example 6.1 using the MATLAB functions. The MATLAB
codes and results for Example 6.1(a) with the nonzero initial conditions are listed as
» B ¼ [0 1]; A ¼ [1 0 0.5];
» x ¼ [1 0.5 0.25 0.125];
» Xi ¼ [ 1 0];Yi ¼ [0 1];
» Zi ¼ filtic(B, A, Yi, Xi);
» y ¼ filter(B, A, x, Zi)
y ¼
0.5000 1.0000 0.2500 0.7500
»
For the case of zero initial conditions in Example 6.1(b), the MATLAB codes and results are
» B ¼ [0 1]; A ¼ [1 0 0.5];
» x ¼ [1 0.5 0.25 0.125];
» y ¼ filter(B, A, x)
y 0 1.0000 0.5000 0.7500
»
As we expected, the filter outputs match the ones in Example 6.1.
Search WWH ::




Custom Search