Discrete-Time Systems 491

8.3 Discrete-Time Systems 491

Now if x[n] is the input to the filter according to the convolution sum, its output is

y[n] =

x[n − k]h[k] = h[0]x[n] + h[1]x[n − 1] + h[2]x[n − 2]

k =0

x[n] + x[n − 1] + x[n − 2]

Notice that the lower bound of the sum is set by the impulse response being zero for n < 0, while the upper bound is set by the input being zero for n < 0 (i.e., if k > n, then n − k < 0 and x[n − k] = 0). The convolution sum coincides with the input–output equation. This holds for any FIR filter.

For any input x[n], let us then find a few values of the convolution sum to see what happens as n grows. If n < 0, the arguments of x[n], x[n − 1], and x[n − 2] are negative giving zero values, and so the output is also zero (i.e., y[n] = 0, n < 0). For n ≥ 0, we have

y[0] =

x[0] + x[−1] + x[−2] = x[0]

y[1] =

x[1] + x[0] + x[−1] = ( x[0] + x[1])

y[2] =

x[2] + x[1] + x[0] = ( x[0] + x[1] + x[2])

y[3] =

x[3] + x[2] + x[1] = ( x[1] + x[2] + x[3])

Thus, if x[n] = u[n], then we have that y[0] = 1/3, y[1] = 2/3, and y[n] = 1 for n ≥ 2. (b) Notice that for n ≥ 2, the output is the average of the present and past two values of the input.

Thus, when the input is x[n] = A cos(2πn/N), if we let N = 3 and A be any real value, the input repeats every three samples and the local average of three of its values is zero, giving y[n] = 0 for n ≥ 2; thus the steady-state response will be zero.

The following MATLAB script uses the function conv to compute the convolution sum when the input is either x[n] = u[n] or x[n] = cos(2πn/3)u[n].

%%%%%%%%%%%%%%%%%% % Example 8.23 -- Convolution sum %%%%%%%%%%%%%%%%%% x1 = [0 0 ones(1, 20)] % unit-step input n= −2:19; n1 = 0:19; x2 = [0 0 cos(2 ∗pi∗n1/3)]; % cosine input

h = (1/3) ∗ones(1, 3); % impulse response y = conv(x1, h); y1 = y(1:length(n)); % convolution sums y = conv(x2, h); y2 = y(1:length(n));

C H A P T E R 8: Discrete-Time Signals and Systems

Convolution sums for

a moving-averaging

filter with input x −1

1 [n] = u[n] and 0 5 10 15 −0.1 0 5 10 15 x 2 [n] = cos(2πn/3)u[n].

Notice that each of the input sequences has two zeros at the beginning so that the response can

be found at n ≥ −2. Also, when the input is of infinite support, like when x[n] = u[n], we can only approximate it as a finite sequence in MATLAB, and as such the final values of the convolu- tion obtained from conv are not correct and should not be considered. In this case, the final two values of the convolution results are not correct and are not considered. The results are shown in Figure 8.10.

■ Example 8.24

Consider an autoregressive system represented by a first-order difference equation

y[n] = 0.5y[n − 1] + x[n]

n ≥0

Find the impulse response h[n] of the system and then compute the response of the system to x[n] = u[n] − u[n − 3] using the convolution sum. Verify results with MATLAB.