Digital Signal Processing Reference
In-Depth Information
Solution
The M
ATLAB
code used to solve the difference equation is listed below. The
explanation follows each instruction in the form of comments.
>> k = [0:50]; % time index k = [-1, 0, 1,
% ...50]
>> X = 0.5.ˆk.*(k>=0); % Input signal
>>A=[110.25]; % Coefficients with y[k]
>>B=[100]; %Coefficients with x[k]
>> Zi = filtic(B,A,[1 -2]); % Initial condition
>> Y = filter(B,A,X,Zi);
% Calculate output
The output response is stored in the vector
Y
. Printing the first five values of
the output response yields
Y = [0.5000 -0.2500 0.3750 -0.1875 0.1563
-0.0781 0.0547].
To confirm if the M
ATLAB
code is correct, we also compute the values of
the output response in the range 0
≤
k
≤
5. We express
y
[
k
+
2]
+
y
[
k
+
1]
+
0
.
25
y
[
k
]=
x
[
k
+
2] as follows:
y
[
k
]
=−
y
[
k
−
1]
−
0
.
25
y
[
k
−
2]
+
x
[
k
]
,
with ancillary conditions
y
[
−
1]
=
1 and
y
[
−
2]
=−
2. Solving the difference
equation iteratively yields
y
[0]
=−
y
[
−
1]
−
0
.
25
y
[
−
2]
+
x
[0]
=−
1
−
0
.
25(
−
2)
+
1
=
0
.
5
,
y
[1]
=−
y
[0]
−
0
.
25
y
[
−
1]
+
x
[1]
=−
0
.
5
−
0
.
25(1)
+
0
.
5
=−
0
.
25
,
y
[2]
=−
y
[1]
−
0
.
25
y
[0]
+
x
[2]
=−
(
−
0
.
25)
−
0
.
25(0
.
5)
+
0
.
25
=
0
.
375
,
y
[3]
=−
y
[2]
−
0
.
25
y
[1]
+
x
[3]
=−
0
.
375
−
0
.
25(
−
0
.
25)
+
0
.
125
=−
0
.
1875
,
y
[4]
=−
y
[3]
−
0
.
25
y
[2]
+
x
[4]
=−
(
−
0
.
1875)
−
0
.
25(0
.
375)
+
0
.
0625
=
0
.
1563
,
and
y
[5]
=−
y
[4]
−
0
.
25
y
[3]
+
x
[2]
=−
0
.
1563
−
0
.
25(
−
0
.
1875)
+
0
.
031 25
=−
0
.
0782
,
which are the same as the values computed using M
ATLAB
.
The expressions for the initial conditions for the higher-order difference equa-
tions are more complex. Fortunately, most systems are causal with zero ancillary
conditions. The initial conditions
Zi
are zero in such cases.
Search WWH ::
Custom Search