Chapter 2
Chapter 2
;t )(e["'-J~x:Gtt]
J ct CD...,r,e~-vct l ~eJ se~. XotvtJ ;~ ccc.llecl ~"Jjt.tj'l+t"-cUoJi;l SJ&o1~e~r1c ;f x.[.,_] =-X:[-rtJ.
11\.,j ~t-{-vqv] Co'"'lf\ex- vet t"' eJ Seft.4~~ xt "l) COU, be Je..cowtf•~eJ \ "'t6
XLV\.)= Xe[~J + Xe[vt] vJhe-ve Xe[a.t) Wo~J Xo[vt] CJJrf j\ve,.., ~J
Discrete-Time Signals
and Systems
This chapter reviews some of the basic principles and definitions of digital signal pro-
cessing. It uses several representations for signals, including functional expressions,
graphs, and sequences of numbers. Pictorial representations of signals are particu-
larly useful because they provide visual insight. Figure 2.1 graphically represents the
sequence x[n] as a function of the index n.
x[n]
33
34 Dlscret•Time Signals and Systems
f I I I I ~-: "
1
• • • • • • •
• • • -• 1 f- I I T ! "' n n
The signal processing literature is filled with many terms that describe signals.
These constitute a basic DSP vocabulary. These terms and acronyms are usually based
Sec.2.1 Dlscret•nme Signals 35
on general characteristics of the signal. One such characteristic is whether the se-
quence is of finite or infinite length. A finite length sequence has a leftmost nonzero
sample and a rightmost nonzero sample. The unit impulse is an example of a finite
length sequence. An infinite length sequence extends infinitely far in one or both of
the two directions. The unit step, exponential, and sinusoid are all examples of infinite
length sequences.
Another useful signal characteristic is periodicity. A periodic sequence, x[n], is
infinite in duration and satisfies the relationship
where the subscripts e and o denote the even and odd parts, respectively. Examining
sequences in terms of their symmetry can sometimes greatly simplify their analysis and
enable difficult problems to be solved in a simple way.
Summations involving sequences often arise in analyzing discrete-time systems.
These summations can be expressed explicitly using the summation operator, E· How-
ever, in many cases these summations can be reduced to compact, closed-form expres-
sions. Three of these can be derived from the geometric series:
~ n_1-aN (2.2)
L-a - 1-a' V a,
n=O
00 1
"""an= - ,
L- 1-a
if lal < 1; (2.3)
n=O
and
00
""" a
L-nan = (1-a)2' if lal < 1. (2.4)
n=O
Equation (2.2) is valid for all complex values of the parameter a. Equation (2.3) is
obtained by taking the limit of (2.2) as N goes to infinity. This is subject to the con-
dition that lal < 1. Equation (2.4) is related to equation (2.3) by differentiation. The
exercises that follow explore some properties of sequences in more depth.
(a) The signal, aa[n- N], is said to be time shifted by N where N is an integer. This
means that the signal, aa[n], is translated by N samples to the right if N > 0
and/or by INI samples to the left if N < 0. 1b illustrate this relatively simple con-
cept, consider the following exercise. Begin by displaying the S-point sequence,
aa[n], that may be found in the file aa using the x view function.
(I) Sketch aa[n].
(II) Sketch aa[n - 2].
(Ill) Sketch aa[n + 4].
Now check your sketches by using the computer. Use the x lshift function
to perform the time shifting. Note that specifying positive integers shifts to the
right; specifying negative ~tegers shifts to the left.
(b) The signal, aa[-n], is said to be time reversed. This means that the signal is flipped
about the point n = 0.
(I) Sketch aa[-n].
(II) If v[n] = aa[n- 4], sketch v[-n].
(ill) If r[n] = aa[n + 2], sketch r[-n].
Again check your sketches using the computer. Use the function x reverse to
perform the time reversal.
h[n] = an u[n]
This should be done initially without the aid of the computer, but you may use the
functions x lshift, x subtract, x truncate, x reverse, and x view to
check your results.
Sec. 2.1 Discrete-Time Signals 31
y[n] = x[/[n)]
where /[n] is the time axis alteration function. The value of /[n] must be an integer
because the time index for digital sequences is only defined for integer values. As a
simple example of time axis alteration, consider the problem of determining
y[n] = x[n - 6]
when
x[n] = u[n]- u[n- 5].
The sequence x[n] is simply shifted to the right by six samples to produce the sequence
y[n]. While this example poses no difficulty, determining the result of other alterations
may not be so easy. For example, consider sketching
y[n] = x[3 - n]
where /[n] = 3- n and x[n] is an arbitrary signal. A simple and systematic procedure
for determining y[n] = x[/[n]] can be summarized as follows:
1. Sketch x[n].
2. Sketch another time ~underneath it for y[n].
3. Write the expression for /[n].
4. 1b find y[O], evaluate /[0] (which will always be an integer). Next evaluate
x[/[0]] and enter this value for y[O] on the time axis for y[n] at the point n = 0.
5. 1b find y[1], evaluate /[1] and x[/[1]]. Set y[1] = x[/[1]] and enter it on the
y[n] time axis at the point n = 1.
6. Continue this procedure until all values, -oo < n < oo, of y[n] have been
found.
1b test your understanding, consider the sequence x[n] where
I x[n] = ur (u[n]- u[n- 5]).
I (a) Without the aid of the computer, sketch
using the procedure just described.
y[n] for each of the cases given below
I
I
40 Discrete-Time Signals and Systems
(b) Develop a rule based on using the x lshift and x reverse operations that can
be used to obtain y[n] for each ofthe cases in part (a). Use x siggen to generate
the damped exponential sequence segment, x[n). Write a macro (as described in
Section 1.3) using the x reverse and x lshift functions that will produce y[n)
for each of the cases in part (a). Indicate the specific shift parameter values that
must be used in order for your macro to work properly. Check to verify that the
answers obtained manually agree with those produced by your macro.
(c) Manually sketch the sequence
y[n) = x[2n).
00
at= L (it
n=O
c
00
a3= 2
5
L (it·
n=5
10
b1 = L:(it
n=O
Sec.2.1 Discrete-Time Signals 41
0
~=a1 L 2n - i
n=-10
16
t>:J= a2 L: Ht
n=6
I o('l., '
10
b4 = aa L (~ t+ 2
• , 3 = Y
n=O
oo t . n t]
x[n] = [ ~(l + 1) (!) + ~ (i) u[n].
(c)
I x[n] =
n-10
t~o (i)t u[n].
]
(d)
"- (1-o<tt) 1
n·ot'~ 1 (n+l} ·o<"+ 1+o<
I L
~:o
I( . o( =:
o(
( l-o<)2.
-
tt·o(l\...
I -o(
- ~--=----;:.........;..~-:'"-----
(I -ad~.
42 Dlserete-Time Signals and Systems
x[n] = cos(Won).
(l) Assume wo = 1r /8. Is this signal periodic? If so, determine its period and
sketch one period of x{n].
(li) Now let wo = 1. Is the discrete-time signal, x[n], periodic? Now consider
the continuous-time signal,
x(t) =cost.
What is the period of this signal? Explain why the discrete-time and continu-
ous-time cosine signals behave differently.
(b) The signal
(c) Using the 40-point signal x[n] defined in part (b), manually sketch each of the
signals shown below:
Yo[n] = 110 x[n]l
Y1 [n] = Lx* [n]
Y2[n) = Re{jx[n]}
Y3[n] = 9m{(jx[n])*}.
Now verify your results using the computer. The x view function will allow
you to display the real and imaginary parts as well as the magnitude and phase.
The x gain function (with gain = 0 1} can be used to generate jxfn]; the x
conjugate function wi11 generate x*[n).
Sec. 2.2 Dlacr8le-Time Syatema a
2.2 DISCRETE·TIME SYSTEMS
A discrete-time system can be viewed as a set of manipulations performed on one or
more sequences. This text will primarily consider single input single output systems,
since these represent the most common systems in traditional digital signal processing
applications. Figure 2.3 depicts a typical system with input x[n] and output y[n]. The
input/output relationship can be written as y[n] = T{x[n]} where T{·} denotes the
system operation. Systems are commonly diScussed and classified in terms of specific
properties, some of which are now defined:
• Additivity. A system is additive if
T{ax[n]} = aT{x[n]}
for aU complex values of a, and for all x[n).
• Linearity. A system is linear if it js both additive and homo&e;neous.
• Tune Jnvariance or Shift Jnvariance. A system is time invariant if a time shift in
the input results in time shifting the output by the same amount. In other words,
given that
y[n] = T { x[n]}
is not causal since x[n + 1] is a future sample of the input. To see this clearly,
assume that the present time is n = 1. Then y[1] = x[1] +x[2]. We see that y[1]
1This is called bounded input bounded output (BIBO) stability. There are other definitions of stability,
but they will not be treated in this text.
44 Discrete-Time Signals and Systems
requires that the present value x(1) and the future value x[2) be known. The
system
_x[_~--~.~~---T-{·-}--~-~~_[n_J_
Figure 2.3. Block diagram representation of a system with input z(n) and output y(n].
Syst~ms that are both linear and time invariant (LTI) are of special significance
because they are well understood and can be conveniently analyzed in both the time
domain and the frequency domain. The following exercises are designed to help you
classify several unknown systems in terms of their properties. These systems, sys-
tem!, system2, and system3, are provided as part of the software. Execution
of these systems is best illustrated by an example. To execute system I, for example,
you should simply type
..
Sec. 2.2 Dlscret•Time Systems 45
Note that if a counterexample is found that violates the linearity tests, one can be
certain that the system is nonlinear. Proving that a system is linear based on this kind
of probing is not practical since the definition requires that the linearity conditions be
satisfied for all possible inputs.
1
y[n) = z[n)
is reasonably well behaved except when the numerical value of z[n) is close to zero.
When x[n) = 0, the output is clearly infinite and therefore the system is unstable.
Consider the system described by the relationship
y[n) = e~lnl.
L lh[nJI < oo
n=-oo
then the LTI system is stable. The impulse responses for several LTI systems are listed
below. Determine if they are stable.
I particular, consider the same noncausal system of part (a) with a three sample
system delay, i.e.,
I delayed in time. Moreover, note that the new system is causal. If the input to the
I
48 Discrete-Time Signals and Systems
system is x(n] = u(n] - u(n - 4], determine the first four samples of the output
analytically.
(c) The idea of using a system delay to make a noncausal system causal as discussed
in part (b) has limitations. For example, if
y(n] = x[n]x[ -n]
it is not possible to find a finite length delay to implement this system as a causal
one. Find another noncausal system for which a causal implementation cannot
be found by using a system delay.
2.3 CONVOLUTION
The impulse response of a system is the response of that system to a discrete-time im-
pulse or unit sample. The impulse response has particular significance when a system
is LTI because it completely characterizes the system. The impulse response provides
all of the information that is necessary to determine the output of an LTI system in
every situation. The output, y[n], of an LTI system is given by the convolution of the
input, x[n], with the system impulse response, h[n]. This operation can be written as
the convolution sum,
00
(a) Write a program, in any language that is supported in your computing environ-
ment, that will read in two sequences, convolve them, and write out the result.
Sec. 2.3 Convolution 41
Use the signal format described in Section 1.2 in your program so that it will be
compatible with the other functions that are provided. 11y to make the program
as short and efficient as possible. Only a few lines of code should be needed for
the program.
(b) The fWtction x convolve, which is provided, also performs linear convolution.
Generate two ramp functions using x siggen, one of length 15 and the other
of length 10. Convolve these two seq.uences and provide a sketch of the two
inputs and the output. Now use your program from part (a) to perform the same
convolution and verify that your program works correctly.
(a) The sequence aa[n) is provided for you in the file aa Use the block option of the
function x siggen to generate x [n). Sketch and display both of these sequences.
(b) Now create the four individual signals, c5[n), c5(n-l], c5[n- 2), and c5[n-3) using x
siggen. This can be done using the block option with different starting locations
for the length 1 sequences. Sketch these sequences.
(c) Using the x convolve function create the sequence y[n) = aa[n) • x[n) and
I J
sketch the result. j [Yl] =o(o( II'\.J -t "<'"(' l 111 -1 -to<o<l VJ- .z] -to(-<l VI- 3
J
(d) Again using the x convolve function, convolve aa[n) with each of the four
sequences that you generated in part (b). Sketch these individual sequences.
I (e) Add the resulting sequences from part (d) together using the x add function
and sketch the result. Use x view2 to compare the result with the result of part
I (b). Observe that the sum is identical to the sequence obtained by convolution.
50 Dtscret•Time Signals and Systems
The important point here is that any input sequence can be represented as a superpo-
sition of delayed unit impulses. The output is then equal to the same superposition of
delayed unit impulse responses.
- EXERCISE 2.3.3. Introduction to Graphical Convolution
Graphical convolution is a straightf01ward and intuitive procedure to cwaluate the
convolution sum without the aid of a computer. The method is motivated by rec-
ognizing that the term h[n - m) in the convolution summation (2.S) can be inter-
preted as a signal in the variable m with n interpreted as a shift parameter. Since
h[n- m] = h[-(m- n)), it is a time-reversed copy of h[m) that is then shifted by n
samples on the m-axis. Thus, given h[n), h[n-m) can be obtained by first reflecting the
signal on the m-axis about the point m = 0 to form h[-m) and shifting it In! places to
the left if n is negative-or n places to the right if n is positive. This is illustrated in Fig.
2.4. The convolution at sample n can now be found by displaying x[m] and h[n-m) on
a common m-axis, multiplying the two aligned sequences on a point-for-point basis,
and summing the products. This exercise will walk through this procedure one step at
a time.
• • • II I .
0 1 2 3
t • ..
n • •n-3 t! I I
n
• • .. m
Figure 2.4. The reflected impulse response of the convolution sum expressed as a sequence.
bb and
(a) First examine the sequences x[n) and h[n) that are provided in the files
cc, respectively, using x view. As you go through the procedure for the first
time, sketch each of the shifted signals on graphs that are aligned vertically.
(i) Reflect the sequence h[n) about the origin using the x reverse function.
Display and sketch your results. This is the signal h[-m).
(ii) To find h[no - m) at an arbitrary value n = no, shift the reflected sequence
no places to the right for no > 0 or lnol places to the left for no < 0. For this
example, begin by finding the value of y[2), i.e., no = 2. Use the x lshift
function to slide the reflected signal two places to the right. Display and
sketch your result.
(iii) Now that the two sequences h[m) and x[2 - m) are aligned, multiply them
pointwise using the x multiply function. Display and sketch your result.
(iv) Add all the sample values in the product sequence together and assign that
value to y[no] (in this case y[2]). Do this step manually by printing the signal
file to the screen. For this example, the correct value is -11. Therefore on
a separate sheet of paper, record y[2) graphically with a height of -11.
Sec. 2.3 Convolution 11
(Y) Repeat this procedure for all values of n, -oo < n < oo. In practice it is
obviously not necessary to do this an infinite number of times when finite
duration sequences are being convolved. Observe that shifting the reflected
sequence too far to the left or right results in nonoverlapping sequences,
in which case the result of the multiplication is an all-zero sequence. It is
typical to start with the shift corresponding to the leftmost nonzero value of
the output and increment n until the convolution is complete.
(b) Given this step-by-step illustration of the procedure, determine and sketch the
complete sequence y(n]. Observe that y(n] is zero outside the range 0 $ n $ 7.
Moreover, observe that the total length of the output sequence is one less than
the sum of the lengths of the two sequences that are convolved. Use the function
x convolve to check your answer.
(c) Determine and sketch y(n] using graphical convolution by reflecting x(n] instead
of h[n]. Verify that your result is the same.
After this procedure becomes familiar, you should be able to reflect and align these-
I quences mentally to obtain a quick estimate of output values for simple convolutions.
2
vl[n] = L c5(n- 6m} J ._v -t S''[Y\- {; _.. ln 12]
m=O
3 2
V2[nJ=EEc5ln-6m-kl =u["'-1J -tV 1 [YJ-2 _.
k=lm=O
(II) Ys[n] = v[n] * z[n]; tt .:: - \1..\0.l S., ; .2.S 3 , "'js) "" \ 4 \. 0 I.J) I
(Ill) Y6[n] =z[n] •w[n]. Vl_.:: -l"o.Stl: lqL\ 1 ~e."' -t ~ l;,)~ '1.\l.O{,(; I
[! ] . n :: -I L\ og 2..0. 12 where z[n] = u[n + 140820] - u[n - 213]. Note that ~e length of z[n] exceeds
I
,. · ' ~ the signal length limit of the software. Hence you cannot use the computer to il
" z.) -14 to~~ get the correct answer. .
x2[n] = 2nu[-n}
xa[n] = u[n] - u[n- 10]. I I
{)sing graphical convolution, sketch the general shape of the following infinite length
signals.
l
(a)
(b)
Ya[n] = * x1 [n].
x1 [n]
(a) Find and sketch the impulse response, h[n], of the system T{·}. Use the block
option of x siggen to create the impulse.
(b) Compute and sketch yi[n] = T{xt[n]} where xt[n] = 26[n- 3]. Use the state-
ment
systeml inputfile outputfile
to implement systeml and x siggen to generate XI [n]. _Compute and sketch
Y2[n] = xi[n] • h[n] using x convolve.
(c) Do the sequences yi[n] and y2[n] suggest that T{-} is LTI? Explain.
Sec. 2.4 Difference Equations 51
Since this system is linear and causal, no nonzero output sample is produt.ed until a
nonzero input sample is received. The input in our example begins at n ::= (II. There-
fore all samples in the output sequence will be zero until this time and tbedw"t can
begin at n = 0. On the line corresponding ton= 0, x(O] = 1 and x[-1] = *1] = 0.
Substituting these values into the difference equation gives y(O] = 1. This pocedure
can be continued by going to the next line, entering the values for y(O], x[fj;., 1Uld x(O],
and then evaluating y(1] using the difference equation and continuing simillarly until
all the desired samples of y(n] have been computed.
(a) Following this procedure, fill in the lines for n = 2, 3, 4. The column 811 the chart
labeled y(n] is the system output.
(b) A computer is ideally suited to evaluate the output samples specified by a dif-
ference equation. Use x siggen to create the input, then use x Jccde to
compute the output. Record the first seven values of y(n] by typing abe output
file to the screen.
(a) Determine the impulse response, h(n], of this system by evaluating the difference
equation using an impulse as the input and zero for the initial condition at n =
-1. The function x siggen can be used to create the impulse and the function
-
x lccde will implement the difference equation. The impulse respoJJJe has the
form
h(n] = o."u(n]. }3
What is the value of o.? Note that we can implement this system even though its
impulse response is infinite in duration.
1
(b) In part (a) you found the impulse response and observed that it was infinitely { 2._ ~
long. If it can be assumed that all values of h(n] less than 0.001 are negligible = 0
and can be ignored, what is the effective length of h(n]? You may find it more
convenient to read the sequence amplitude values by typing the signal file to the ·*"" [.
screen or by using a text editor rather than by using x view. Generate this finite
length version of h(n] and the sequence I [ J _(
2.!)., f [
.,_tY ~ .- 31 z_ti [t'lj-
x(n] = u(n] - u(n - 6]
using x siggen. Compute and sketch x(n] * h[n].
il
Sec. 2.4 Difference Equations 17
(c) Now implement the convolution in part (b) explicitly using a difference equation.
Use the x lccde function with zero initial conditions. Compare your results
with the sequence obtained by convolution. By using the function x subtract
display and sketch the difference between the two results. How many multiplies
and adds are required on average to obtain each output sample using both of
these methods?
tria(t) = t u(t)- 2(t- 20) u(t- 20) + (t- 40) u(t- 40).
Now compute (by inspection) and sketch the first derivative of each of these
continuous-time waveforms.
(b) Generate the 41-point triangular pulse
tri[n] = nu[n]- 2(n- 20) u[n- 20] + (n- 40) u[n- 40].
This can be done easily using the triangular wave option in x siggen by specify-
ing the period to be 40 and the number of periods to be one. In addition, generate
and sketch the square pulse
Use the square wave option in x siggen with pulse length 20, period 40, and
number of periods 1. Now compute and sketch the first backward difference
58 Discrete-Time Signals and Systems
of each of these signals using either x lccde to implement the system using
equation (2.7) or x convolve. Note the similarity to the continuous-time case.
The function x view2 may be used to display the signal and its first backward
difference one above the other. In many cases the first backward difference is
used as an approximation to a derivative operator.
y[n] = L x[k].
A:=-oo
sin(~n).
Generate this sequence by using the sine wave option in x siggen with
alpha =1r /40, phi = 0 and length = 128.
Evaluate and sketch the running sum of each of these signals. Compare these
results with the results found for the continuous-time case in part (a). You should
observe that the running sum performs like a discrete-time integrator.
h[n + 1] = c h[n]
I f[n + 1] = h[n + 1] /[n].
To begin the recursion, a value for h[O] is needed. Observe from the equation
that h[O] = /[0]//[- 1]. The initial conditions for f[n] can be obtained from
equation (2.9). Write a program that implements this simple pair of equations
and evaluate the Gaussian as in part (b). Compare the results in all three cases.
What is the maximum error?
I
80 Dlacret•Time Signals and Syatema
00
If v[n] and w[n] are equal, the cross correlation and autocorrelation are identical.
Cross correlation also has a convolutional interpretation,
1 if x[n] ~ 0
x[n] =
4 {
-1 if x[n] < 0
I
I
82 Discrete-Time Signals and Systema
v(n] ~ 0
v[n] < 0.
Use the x quantize function to do this with min = -1 and max = 1 and the
number of levels equal to two. Compute the cross correlation function of z(n]
and v(n]. Use x view2 to display this cross correlation function and the one
in part (a) simultaneously. What is the required shift in v(n] to produce the best
alignment using this approach? How many multiplies and adds are required?
How do the methods in parts (a) and (b) compare? (Note: Multiplication by +1
or -1 should not be counted as a multiply.) You will not observe any speedup
in the software that is provided because those programs do not check to avoid
multiplications by ±1.
(c) 1\vo random signals generated with different seed values should not bear any sim-
ilarity to each other and are said to be uncorrelated. Consequently, they should
not produce a cross correlation function with a dominant peak indicating a pre-
ferred alignment. Use x rgen and x lshift as before to create another random
sequence, y(n], (with a different seed) in the same range. Display and sketch the
cross correlation of z(n) and y(n). Observe that there is no dominant peak that
clearly marks a "best alignment" between the two sequences.
(a) Generate a uniform random sequence z 1 (n) of length 128 usingx rgen. Use the
x gain function to multiply the sequence by 100 to produce a random sequence,
y(n), with amplitude values in the range -50 to 50. 1b examine the distribution
of y(n), compute and display its histogram using x histogram and x view.
The histogram is a plot of sample amplitude on the z-axis versus the number of
occurrences of that amplitude on the y-axis. If the histogram is roughly flat, the
sequence is said to be uniformly distributed.
(b) Now generate eight additional random sequences z2[n), z3(n), ... , zg(n). Add
the sequences z 1 (n], ... , x 9 (n) together using x add to form Y2(n]. Multiply
y2 (n] by 11 so that its amplitude range will be from -50 to +50. Display and
sketch the histogram of the new sequence. Does this distnbution more closely
resemble that of a Gaussian random sequence?
1\vo uncorrelated (and therefore independent) Gaussian random variables, 9I[n] and
92[n] can then be formed using the equations
(a) Write a macro that will accept a uniform random sequence as its input and pro-
duce 9I[n] and 92[n] as its outputs. The functions x divide, x log, x mul-
tiply, x lshift, and x nlinear will be helpful in computing r[n]. Use your
macro to generate 9I[n] and 92[n] with u = 1 and length 1024. List all necessary
functions and intermediate signal files in your macro. Note that the random sig-
nal XI [n] should have an amplitude range between 0 and 1. Therefore you should
add a block sequence with amplitude .5 to the random sequence generated by
x rgen in constructing xi [n].
(b) Determine the maximum absolute value A for 9I[n] and 92[n]. Multiply each
by 1000/A so that the amplitude range of each signal will be between -500 and
+500. Now compute the histogram of 9I [n] and 92[n] and sketch the results.
Does this distnbution appear to be Gaussian?
(c) Cross correlation was introduced in Exercise 2.4.7. Compute the cross correla-
tion function for 9I [n] and 92[n]. Do these sequences appear to be uncorrelated?
Justify your conclusion.
2.5 REFERENCES
[1] J. E Kaiser, "On the Fast Generation of Equally Spaced Values of the Gaussian
Function A exp (-at* t)," IEEE Transactions on Acoustics, Speech, and Signal
Processing, Vol. ASSP-35, No. 10, pp. 1480-1481, Oct. 1987.
[2] L. Rabiner and B. Gold, Theory and Application ofDigital Signal Processing, Prentice-
Hall, Englewood Cliffs, NJ, 1975.