8.3 Discrete-Time Systems 497
0 20 40 60 80 100
(a)
120140160180 200
− 2
− 1
0
1
2
n
y^1
[n
]
(b) (c)
0 20 40 60 80 100 120 140 160 180 200
n
0 20 40 60 80 100 120 140 160 180 200
n
− 2
− 1
0
1
2
z^1
[n
]
z^2
[n
]
− 2
− 1
0
1
2
FIGURE 8.13
Top figure (a): noisy signal (dashed blue line) and clean signal (solid line). The clean signal (dashed line) is
superposed on the denoised signal (solid blue line) in the bottom plots. The solid line in plot (b) is the result of
median filtering, and the solid line in plot (c) is the result of the averager.
x = [2∗cos(pi∗n(1:100)/256) zeros(1, 100)];
y1 = x + noise;
% linear filtering
z2 = averager(15, y1);
% nonlinear filtering -- median filtering
z1(1) = median([0 0 y1(1) y1(2) y1(3)]);
z1(2) = median([0 y1(1) y1(2) y1(3) y1(4)]);
z1(N−1) = median([y1(N−3) y1(N−2) y1(N−1) y1(N) 0]);
z1(N) = median([y1(N−2) y1(N−1) y1(N) 0 0]);
for k = 3:N−2,
z1(k) = median([y1(k−2) y1(k−1) y1(k) y1(k + 1) y1(k + 2)]);
end
Although the theory of nonlinear filtering is beyond the scope of this book, it is good to remember
that in cases like this when linear filters do not seem to do well, there are other methods to use.
8.3.5 Causality and Stability of Discrete-Time Systems
As with continuous-time systems, two additional independent properties of discrete-time systems are
causality and stability. Causality relates to the conditions under which computation can be performed
in real time, while stability relates to the usefulness of the system.
Causality
In many situations signals need to be processed in real time—that is, the processing must be done
as the signal comes into the system. In those situations, the system must be causal. In many other