DSP - Using Matlab - Chap2
DSP - Using Matlab - Chap2
Discrete-time
Signals and
Systems
Signals are broadly classified into analog and discrete signals. An analog
signal will be denoted by xa (t), in which the variable t can represent any
physical quantity, but we will assume that it represents time in seconds. A
discrete signal will be denoted by x(n), in which the variable n is integer-
valued and represents discrete instances in time. Therefore it is also called
a discrete-time signal, which is a number sequence and will be denoted by
one of the following notations:
x(n) = {x(n)} = {. . . , x(−1), x(0), x(1), . . .}
↑
where the up-arrow indicates the sample at n = 0.
22
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
Discrete-time Signals 23
Generally, we will use the x-vector representation alone when the sample
position information is not required or when such information is trivial
(e.g. when the sequence begins at n = 0). An arbitrary infinite-duration
sequence cannot be represented in MATLAB due to the finite memory
limitations.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
24 Chapter 2 DISCRETE-TIME SIGNALS AND SYSTEMS
x(n) = an , ∀n; a ∈ R
x(n) = e(σ+jω0 )n , ∀n
5. Sinusoidal sequence:
x(n) = A cos(ω0 n + θ0 ), ∀n
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
Discrete-time Signals 25
Note that the last two lines can be combined into one for compact
coding. This is shown in Example 2.1.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
26 Chapter 2 DISCRETE-TIME SIGNALS AND SYSTEMS
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
Discrete-time Signals 27
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
28 Chapter 2 DISCRETE-TIME SIGNALS AND SYSTEMS
! EXAMPLE 2.1 Generate and plot each of the following sequences over the indicated interval.
a. x(n) = 2δ(n + 2) − δ(n − 4), −5 ≤ n ≤ 5.
b. x(n) = n[u(n)−u(n−10)]+10e−0.3(n−10) [u(n−10)−u(n−20)], 0 ≤ n ≤ 20.
c. x(n) = cos(0.04πn) + 0.2w(n), 0 ≤ n ≤ 50, where w(n) is a Gaussian
random sequence with zero mean and unit variance.
d. x̃(n) = {..., 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, ...}; −10 ≤ n ≤ 9.
↑
1 The symbol * denotes many operations in digital signal processing. Its font (roman
or computer) and its position (normal or superscript) will distinguish each operation.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
Discrete-time Signals 29
>> n = [-5:5];
>> x = 2*impseq(-2,-5,5) - impseq(4,-5,5);
>> stem(n,x); title(’Sequence in Problem 2.1a’)
>> xlabel(’n’); ylabel(’x(n)’);
x(n)
0 4
2
−1
0
−2
−5 0 5 0 5 10 15 20
n n
Sequence in Example 2.1c Sequence in Example 2.1d
6
1
0.5 4
xtilde(n)
x(n)
0
2
−0.5
−1 0
0 10 20 30 40 −10 −5 0 5
n n
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
30 Chapter 2 DISCRETE-TIME SIGNALS AND SYSTEMS
! EXAMPLE 2.2 Let x(n) = {1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1}. Determine and plot the following
↑
sequences.
a. x1 (n) = 2x(n − 5) − 3x(n + 4)
b. x2 (n) = x(3 − n) + x(n) x(n − 2)
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
Discrete-time Signals 31
10
5
0
x1(n)
−5
−10
−15
−20
−6 0 15
n
Sequence in Example 2.2b
40
x2(n) 30
20
10
0
−7 0 12
n
support (or sample positions). These operations can be easily done using the
sigfold and the sigmult functions.
Example 2.2 shows that the four sig* functions developed in this
section provide a convenient approach for sequence manipulations.
and plot its magnitude, phase, the real part, and the imaginary part in four
separate subplots.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
32 Chapter 2 DISCRETE-TIME SIGNALS AND SYSTEMS
1
0
0
−1
−1
−2
−3 −2
−10 −5 0 5 10 −10 −5 0 5 10
n n
Magnitude Part Phase Part
3 200
100
2
1
−100
0 −200
−10 −5 0 5 10 −10 −5 0 5 10
n n
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
Discrete-time Signals 33
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
34 Chapter 2 DISCRETE-TIME SIGNALS AND SYSTEMS
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
Discrete-time Signals 35
1 1
0.8 0.8
xe(n)
x(n)
0.6 0.6
0.4 0.4
0.2 0.2
0 0
−10 −5 0 5 10 −10 −5 0 5 10
n n
Odd Part
0.6
0.4
0.2
xe(n)
0
−0.2
−0.4
−10 −5 0 5 10
n
The sequence and its support are supplied in x and n arrays, respectively.
It first checks if the given sequence is real and determines the support
of the even and odd components in m array. It then implements (2.5)
with special attention to the MATLAB indexing operation. The resulting
components are stored in xe and xo arrays.
! EXAMPLE 2.4 Let x(n) = u(n) − u(n − 10). Decompose x(n) into even and odd components.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
36 Chapter 2 DISCRETE-TIME SIGNALS AND SYSTEMS
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
Discrete Systems 37
In DSP we will say that the system processes an input signal into an output
signal. Discrete systems are broadly classified into linear and nonlinear
systems. We will deal mostly with linear systems.
L[a1 x1 (n) + a2 x2 (n)] = a1 L[x1 (n)] + a2 L[x2 (n)], ∀a1 , a2 , x1 (n), x2 (n)
(2.10)
Using (2.3) and (2.10), the output y(n) of a linear system to an arbitrary
input x(n) is given by
& ∞ ' ∞
$ $
y(n) = L[x(n)] = L x(k) δ(n − k) = x(k)L[δ(n − k)]
n=−∞ n=−∞
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
38 Chapter 2 DISCRETE-TIME SIGNALS AND SYSTEMS
For an LTI system the L[·] and the shifting operators are reversible as
shown here.
! EXAMPLE 2.6 Determine whether the following linear systems are time-invariant.
1. y(n) = L[x(n)] = 10 sin(0.1πn)x(n)
2. y(n) = L[x(n)] = x(n + 1) − x(1 − n)
3. y(n) = L[x(n)] = 14 x(n) + 12 x(n − 1) + 14 x(n − 2)
%
Solution First we will compute the response yk (n) = L[x(n − k)] to the shifted
input sequence. This is obtained by subtracting k from the arguments of
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
Discrete Systems 39
every input sequence term on the right-hand side of the linear transforma-
tion. To determine time-invariance, we will then compare it to the shifted
output sequence y(n − k), obtained after replacing every n by (n − k) on
the right-hand side of the linear transformation.
1. y(n) = L[x(n)] = 10 sin(0.1πn)x(n): The response due to shifted
input is
We will denote an LTI system by the operator LT I [·]. Let x(n) and
y(n) be the input-output pair of an LTI system. Then the time-varying
function h(n, k) becomes a time-invariant function h(n − k), and the out-
put from (2.11) is given by
∞
$
y(n) = LT I [x(n)] = x(k)h(n − k) (2.13)
k=−∞
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
40 Chapter 2 DISCRETE-TIME SIGNALS AND SYSTEMS
2.3 CONVOLUTION
! EXAMPLE 2.7 Let the rectangular pulse x(n) = u(n) − u(n − 10) of Example 2.4 be an input
to an LTI system with impulse response
h(n) = (0.9)n u(n)
Determine the output y(n).
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
Convolution 41
Input Sequence
2
1.5
x(n)
1
0.5
0
−5 0 5 10 15 20 25 30 35 40 45
n
Impulse Response
2
h(n) 1.5
0.5
0
−5 0 5 10 15 20 25 30 35 40 45
n
FIGURE 2.5 The input sequence and the impulse response in Example 2.7
Solution The input x(n) and the impulse response h(n) are shown in Figure 2.5. From
(2.14)
$
9
$
9
The sum in (2.17) is almost a geometric series sum except that the term u(n−k)
takes different values depending on n and k. There are three possible conditions
under which u(n − k) can be evaluated.
y(n) = 0 (2.18)
CASE ii In this case the nonzero values of x(n) and h(n) do not overlap.
0 ≤ n < 9: Then u(n − k) = 1, 0 ≤ k ≤ n. Hence from (2.17)
$
n
$
n
1 − (0.9)−(n+1)
= (0.9)n = 10[1 − (0.9)n+1 ], 0≤n<9 (2.19)
1 − (0.9)−1
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
42 Chapter 2 DISCRETE-TIME SIGNALS AND SYSTEMS
Output Sequence
8
y(n)
4
0
−5 0 5 10 15 20 25 30 35 40 45
n
CASE iii In this case the impulse response h(n) partially overlaps the input x(n).
n ≥ 9: Then u(n − k) = 1, 0 ≤ k ≤ 9 and from (2.17)
$
9
This example can also be done using a method called graphical convo-
lution, in which (2.14) is given a graphical interpretation. In this method,
h(n − k) is interpreted as a folded-and-shifted version of h(k). The output
y(n) is obtained as a sample sum under the overlap of x(k) and h(n − k).
We use an example to illustrate this.
Solution In Figure 2.7 we show four plots. The top-left plot shows x(k) and h(k), the
original sequences. The top-right plot shows x(k) and h(−k), the folded version
of h(k). The bottom-left plot shows x(k) and h(−1 − k), the folded-and-shifted-
by- −1 version of h(k). Then
$
x(k)h(−1 − k) = 3 × (−5) + 11 × 0 + 7 × 3 + 0 × 2 = 6 = y(−1)
k
The bottom-right plot shows x(k) and h(2 − k), the folded-and-shifted-by-2
version of h(k), which gives
$
x(k)h(2 − k) = 11 × 1 + 7 × 2 + 0 × (−5) + (−1) × 0 + 4 × 3 + 2 × 2 = 41 = y(2)
k
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
Convolution 43
5 5
0 0
n=0
−5 −5
−5 0 5 −5 0 5
k k
x(k) and h(−1−k) x(k) and h(2−k)
Solid: x Dashed: h Solid: x Dashed: h
10 10
5 5
0 0
n=−1 n=2
−5 −5
−5 0 5 −5 0 5
k k
Thus we have obtained two values of y(n). Similar graphical calculations can
be done for other remaining values of y(n). Note that the beginning point (first
nonzero sample) of y(n) is given by n = −3 + (−1) = −4, while the end point
(the last nonzero sample) is given by n = 3 + 4 = 7. The complete output is
given by
y(n) = {6, 31, 47, 6, −51, −5, 41, 18, −22, −3, 8, 2}
↑
Students are strongly encouraged to verify the above result. Note that the re-
sulting sequence y(n) has a longer length than both the x(n) and h(n) sequences.
!
>> y = conv(x,h);
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
44 Chapter 2 DISCRETE-TIME SIGNALS AND SYSTEMS
to obtain the correct y(n) values. However, the conv function neither
provides nor accepts any timing information if the sequences have arbi-
trary support. What is needed is a beginning point and an end point of
y(n). Given finite duration x(n) and h(n), it is easy to determine these
points. Let
{x(n); nxb ≤ n ≤ nxe } and {h(n); nhb ≤ n ≤ nhe }
be two finite-duration sequences. Then referring to Example 2.8 we ob-
serve that the beginning and end points of y(n) are
nyb = nxb + nhb and nye = nxe + nhe
respectively. A simple modification of the conv function, called conv m,
which performs the convolution of arbitrary support sequences can now
be designed.
! EXAMPLE 2.9 Perform the convolution in Example 2.8 using the conv m function.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
Convolution 45
Hence
y(n) = {6, 31, 47, 6, −51, −5, 41, 18, −22, −3, 8, 2}
↑
as in Example 2.8. !
where w(n) is Gaussian sequence with mean 0 and variance 1. Compute the
crosscorrelation between y(n) and x(n).
Solution From the construction of y(n) it follows that y(n) is “similar” to x(n − 2) and
hence their crosscorrelation would show the strongest similarity at # = 2. To
test this out using MATLAB, let us compute the crosscorrelation using two
different noise sequences.
% noise sequence 1
>> x = [3, 11, 7, 0, -1, 4, 2]; nx=[-3:3]; % given signal x(n)
>> [y,ny] = sigshift(x,nx,2); % obtain x(n-2)
>> w = randn(1,length(y)); nw = ny; % generate w(n)
>> [y,ny] = sigadd(y,ny,w,nw); % obtain y(n) = x(n-2) + w(n)
>> [x,nx] = sigfold(x,nx); % obtain x(-n)
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
46 Chapter 2 DISCRETE-TIME SIGNALS AND SYSTEMS
200 Maximum
150
rxy
100
50
−50
−4 −2 0 2 4 6 8
Lag Variable l
Crosscorrelation: Noise Sequence 2
200 Maximum
150
rxy
100
50
−50
−4 −2 0 2 4 6 8
Lag Variable l
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
Difference Equations 47
>> xcorr(x,y)
>> xcorr(x)
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
48 Chapter 2 DISCRETE-TIME SIGNALS AND SYSTEMS
y = filter(b,a,x)
where
are the coefficient arrays from the equation given in (2.21), and x is the
input sequence array. The output y has the same length as input x. One
must ensure that the coefficient a0 not be zero.
To compute and plot impulse response, MATLAB provides the func-
tion impz. When invoked by
h = impz(b,a,n);
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
Difference Equations 49
Solution From the given difference equation the coefficient arrays are
a. MATLAB script:
Impulse Response
1
0.5
h(n)
−0.5
−1
−20 0 20 40 60 80 100 120
n
Step Response
1.5
s(n)
0.5
−0.5
−20 0 20 40 60 80 100 120
n
FIGURE 2.9 Impulse response and step response plots in Example 2.11
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
50 Chapter 2 DISCRETE-TIME SIGNALS AND SYSTEMS
we can use the plot of the impulse*response to observe that h(n) is practically
zero for n > 120. Hence the sum |h(n)| can be determined from MATLAB
using
>> sum(abs(h))
ans = 14.8785
which implies that the system is stable. An alternate approach is to use the
stability condition (2.23) using MATLAB’s roots function.
Since the magnitudes of both roots are less than one, the system is stable.
!
In the previous section we noted that if one or both sequences in
the convolution are of infinite length, then the conv function cannot be
used. If one of the sequences is of infinite length, then it is possible to use
MATLAB for numerical evaluation of the convolution. This is done using
the filter function as we will see in the following example.
! EXAMPLE 2.12 Let us consider the convolution given in Example 2.7. The input sequence is of
finite duration
x(n) = u(n) − u(n − 10)
while the impulse response is of infinite duration
h(n) = (0.9)n u(n)
Determine y(n) = x(n) ∗ h(n).
Solution If the LTI system, given by the impulse response h(n), can be described by a
difference equation, then y(n) can be obtained from the filter function. From
the h(n) expression
(0.9) h(n − 1) = (0.9) (0.9)n−1 u(n − 1) = (0.9)n u(n − 1)
or
h(n) − (0.9) h(n − 1) = (0.9)n u(n) − (0.9)n u(n − 1)
= (0.9)n [u(n) − u(n − 1)] = (0.9)n δ(n)
= δ(n)
The last step follows from the fact that δ(n) is nonzero only at n = 0. By
definition h(n) is the output of an LTI system when the input is δ(n). Hence
substituting x(n) for δ(n) and y(n) for h(n), the difference equation is
y(n) − 0.9y(n − 1) = x(n)
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
Difference Equations 51
Output Sequence
8
y(n)
4
0
−5 0 5 10 15 20 25 30 35 40 45
n
Now MATLAB’s filter function can be used to compute the convolution in-
directly.
The plot of the output is shown in Figure 2.10, which is exactly the same as
that in Figure 2.6. !
M
$ N
$
y(n) = bm x(n − m) − ak y(n − k); n ≥ 0 (2.24)
m=0 k=1
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
52 Chapter 2 DISCRETE-TIME SIGNALS AND SYSTEMS
where yZI (n) is called the zero-input solution, which is a solution due
to the initial conditions alone (assuming they exist), while the zero-state
solution, yZS (n), is a solution due to input x(n) alone (or assuming that
the initial conditions are zero). In MATLAB another form of the function
filter can be used to solve for the difference equation, given its initial
conditions. We will illustrate the use of this form in Chapter 4.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
Problems 53
2.5 PROBLEMS
P2.1 Generate the following sequences using the basic MATLAB signal functions and the basic
MATLAB signal operations discussed in this chapter. Plot signal samples using the stem
function.
1. x1 (n) = 3δ(n + 2) + 2δ(n) − δ(n − 3) + 5δ(n − 7), −5 ≤ n ≤ 15.
*5
2. x2 (n) = k=−5
e−|k| δ(n − 2k), −10 ≤ n ≤ 10.
3. x3 (n) = 10u(n) − 5u(n − 5) − 10u(n − 10) + 5u(n − 15).
4. x4 (n) = e0.1n [u(n + 20) − u(n − 10)].
5. x5 (n) = 5[cos(0.49πn) + cos(0.51πn)], −200 ≤ n ≤ 200. Comment on the waveform
shape.
6. x6 (n) = 2 sin(0.01πn) cos(0.5πn), −200 ≤ n ≤ 200. Comment on the waveform shape.
7. x7 (n) = e−0.05n sin(0.1πn + π/3), 0 ≤ n ≤ 100. Comment on the waveform shape.
8. x8 (n) = e0.01n sin(0.1πn), 0 ≤ n ≤ 100. Comment on the waveform shape.
P2.2 Generate the following random sequences and obtain their histogram using the hist
function with 100 bins. Use the bar function to plot each histogram.
1. x1 (n) is a random sequence whose samples are independent and uniformly distributed
over [0, 2] interval. Generate 100,000 samples.
2. x2 (n) is a Gaussian random sequence whose samples are independent with mean 10 and
variance 10. Generate 10,000 samples.
3. x3 (n) = x1 (n) + x1 (n − 1) where x1 (n) is the random sequence given in part 1 above.
Comment *on the shape of this histogram and explain the shape.
4
4. x4 (n) = k=1 yk (n) where each random sequence yk (n) is independent of others with
samples uniformly distributed over [−0.5, 0.5]. Comment on the shape of this histogram.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
54 Chapter 2 DISCRETE-TIME SIGNALS AND SYSTEMS
P2.3 Generate the following periodic sequences and plot their samples (using the stem function)
over the indicated number of periods.
1. x̃1 (n) = {. . . , −2, −1, 0, 1, 2, . . .}periodic . Plot 5 periods.
↑
2. x̃2 (n) = e0.1n [u(n) − u(n − 20]periodic . Plot 3 periods.
3. x̃3 (n) = sin(0.1πn)[u(n) − u(n − 10)]. Plot 4 periods.
4. x̃4 (n) = {. . . , 1, 2, 3, . . .}periodic + {. . . , 1, 2, 3, 4, . . .}periodic , 0 ≤ n ≤ 24. What is the
↑ ↑
period of x̃4 (n)?
P2.4 Let x(n) = {2, 4, −3, 1, −5, 4, 7}. Generate and plot the samples (use the stem function) of
↑
the following sequences.
1. x1 (n) = 2x(n − 3) + 3x(n + 4) − x(n)
2. x2 (n) = 4x(4 + n) + 5x(n + 5) + 2x(n)
3. x3 (n) = x(n + 3)x(n − 2) + x(1 − n)x(n + 1)
4. x4 (n) = 2e0.5n x(n) + cos (0.1πn) x (n + 2) , −10 ≤ n ≤ 10
P2.5 The complex exponential sequence ejω0 n or the sinusoidal sequence cos (ω0 n) are periodic if
# ω0 K
the normalized frequency f0 = is a rational number; that is, f0 = , where K and N
2π N
are integers.
1. Prove the above result.
2. Generate exp(0.1πn), −100 ≤ n ≤ 100. Plot its real and imaginary parts using the stem
function. Is this sequence periodic? If it is, what is its fundamental period? From the
examination of the plot what interpretation can you give to the integers K and N above?
3. Generate and plot cos(0.1n), −20 ≤ n ≤ 20. Is this sequence periodic? What do you
conclude from the plot? If necessary examine the values of the sequence in MATLAB to
arrive at your answer.
P2.6 Using the evenodd function, decompose the following sequences into their even and odd
components. Plot these components using the stem function.
1. x1 (n) = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}.
↑
2. x2 (n) = e0.1n [u(n + 5) − u(n − 10)].
3. x3 (n) = cos(0.2πn + π/4), −20 ≤ n ≤ 20.
4. x4 (n) = e−0.05n sin(0.1πn + π/3), 0 ≤ n ≤ 100.
P2.7 A complex-valued sequence xe (n) is called conjugate-symmetric if xe (n) = x∗e (−n) and a
complex-valued sequence xo (n) is called conjugate-antisymmetric if xo (n) = −x∗o (−n).
Then, any arbitrary complex-valued sequence x(n) can be decomposed into
x(n) = xe (n) + xo (n) where xe (n) and xo (n) are given by
1 1
xe (n) = [x(n) + x∗ (−n)] and xo (n) = [x(n) − x∗ (−n)] (2.27)
2 2
respectively.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
Problems 55
1. Modify the evenodd function discussed in the text so that it accepts an arbitrary
sequence and decomposes it into its conjugate-symmetric and conjugate-antisymmetric
components by implementing (2.27).
2. Decompose the following sequence:
y(n) = x(nM )
y(n) = {. . . , −2, 3, 5, 8, . . .}
↑
to implement the above operation. Use the indexing mechanism of MATLAB with
careful attention to the origin of the time axis n = 0.
2. Generate x(n) = sin(0.125πn), − 50 ≤ n ≤ 50. Decimate x(n) by a factor of 4 to
generate y(n). Plot both x(n) and y(n) using subplot and comment on the results.
3. Repeat the above using x(n) = sin(0.5πn), − 50 ≤ n ≤ 50. Qualitatively discuss the
effect of down-sampling on signals.
P2.9 Using the conv_m function, determine the autocorrelation sequence rxx (#) and the
crosscorrelation sequence rxy (#) for the following sequences.
where k is the amount of delay in samples and α is its relative strength. We want to
estimate the delay using the correlation analysis.
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
56 Chapter 2 DISCRETE-TIME SIGNALS AND SYSTEMS
1. Determine analytically the crosscorrelation ryx (#) in terms of the autocorrelation rxx (#).
2. Let x(n) = cos(0.2πn) + 0.5 cos(0.6πn), α = 0.1, and k = 50. Generate 200 samples of
y(n) and determine its crosscorrelation. Can you obtain α and k by observing ryx (#)?
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
Problems 57
y = Hx
where linear shifts in h(n − k) for n = 0, . . . , Nh − 1 are arranged as rows in the matrix H.
This matrix has an interesting structure and is called a Toeplitz matrix. To investigate this
matrix, consider the sequences
function [y,H]=conv_tp(h,x)
% Linear Convolution using Toeplitz Matrix
% ----------------------------------------
% [y,H] = conv_tp(h,x)
% y = output sequence in column vector form
% H = Toeplitz matrix corresponding to sequence h so that y = Hx
% h = Impulse response sequence in column vector form
% x = input sequence in column vector form
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require
58 Chapter 2 DISCRETE-TIME SIGNALS AND SYSTEMS
1. Using the filter function, compute and plot the impulse response of the system over
0 ≤ n ≤ 100.
2. Determine the stability of the system from this impulse response.
3. If the input to this system is x(n) = [5 + 3 cos(0.2πn) + 4 sin(0.6πn)] u(n), determine the
response y(n) over 0 ≤ n ≤ 200 using the filter function.
P2.20 A “simple” digital differentiator is given by
which computes a backward first-order difference of the input sequence. Implement this
differentiator on the following sequences, and plot the results. Comment on the
appropriateness of this simple differentiator.
1. x(n) = 5 [u(n) − u(n − 20)]: a rectangular pulse
2. x(n) = n [u(n) − u(n − 10)] + (20 − n) [u(n − 10) − u(n − 20)]: a triangular pulse
+ ,
πn
3. x(n) = sin [u(n) − u(n − 100)]: a sinusoidal pulse
25
Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).
Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require