Digital Signal Processing Reference
In-Depth Information
For an
n
-order difference equation, the input variable
yinitial
is set to
yinitial
=
[
y
[
−
1]
,
y
[
−
2]
,...,
y
[
−
n
]]
.
To
illustrate
the
usage
of
the
built-in
function
filter
,
let
us
repeat
Example 10.1 using M
ATLAB
.
Example 10.17
The DT sequence
x
[
k
]
=
2
ku
[
k
] is applied at the input of an LTID system
described by the following difference equation:
y
[
k
+
1]
−
0
.
4
y
[
k
]
=
x
[
k
]
,
with the ancillary condition
y
[
−
1]
=
4
.
Compute the output response
y
[
k
]of
the LTID system for 0
≤
k
≤
50 using M
ATLAB
.
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 = 2*k.*(k>=1); % Input signal
>>A=[1-0.4]; % Coefficients with y[k]
>>B=[01]; %Coefficients with x[k]
>> Zi = filtic(B,A,4); % Initial condition
>> Y = filter(B,A,X,Zi); % Calculate output
The output response is stored in the vector
Y
. Printing the first six values of the
output response yields
Y = [1.6 0.6400 2.2560 4.9024 7.9610 11.1844],
which corresponds to the values of the output response
y
[
k
] for the duration
0
≤
k
≤
5. Comparing with the numerical solution obtained in Example 10.1,
we observe that the two results are identical.
Next we proceed with a second-order difference equation.
Example 10.18
The DT sequence
x
[
k
]
=
0.5
k
u
[
k
] is applied at the input of an LTID system
described by the following second-order difference equation:
y
[
k
+
2]
+
y
[
k
+
1]
+
0
.
25
y
[
k
]
=
x
[
k
+
2]
,
with ancillary conditions
y
[
−
1]
=
1 and
y
[
−
2]
=−
2. Compute the output
response
y
[
k
] of the LTID system for 0
≤
k
≤
50 using M
ATLAB
.
Search WWH ::
Custom Search