Download as pdf or txt
Download as pdf or txt
You are on page 1of 33

ISBN 0-534-4D5H]·X

THOMSON •••••

ENGINEER~NG

9 7

THOMSON

:+

ENGINEERING

-. COPYRIGHT © 2007 by Nelson, a division of Thomson Canada Ltd. Nelson is a registered trademark used herein under license.

For more information contact Nelson, 1120 Birchmount Road, Scarborough, Ontario Ml K 504. Or you can visit our Internet site at www.nelson.com,

ALL RIGHTS RESERVED. No part of this work covered by the copyrighthereon may be reproduced or used in any form or by any means-graphic, electronic, or mechanical, including photocopying, recording, taping, web distribution or information storage and retrieval systems-without the written permission of the publisher.

Table of Contents

Chapter 2 ........ Discrete Signals ~0.pI£l.aell~lloa~IiO"'G"'lllI-ll'Ii:.~ooe.-Q&l!-ellojo"'rloll-"'~'UII"'-0~Cio"-CI"iIIo11r"'~oi-llo!IJoIilli .... Ilo .. IiIi'l-.,.".,O .... "O:O"l'l,Q-Il- ... I!:tQ~ilIlIi-1Io0o!ile{lO-c-Ooli 1 .Chapter.S - Time-Domain Analysis 1i' .. ".,<:l ... "''''lI'''1il ...... @(I'" ... II~(IoOGO&O.floflccrcrao-cr.II-''IioO-cilIlc;-G e e -Q!IOOI)(Io'''O'''(Io"'oEt8IS-(Joo1oi"H~.fiiiiioe- ... OG(H.do(l.(o 30

Chapter 7 - Digital Processing of Analog Signals 196

Chapter 8 - The Discrete Fourier Transform and Its Applications .........•....•........ 241

Chapter 10 ~ Design of FIR Filters Cio&"~;,a ..... lliI- ... d-D" .... Il''''''''~ ... 'H .. ''1iil'''''.,I.,.O''4IO'''''CIiIlG-'''O'''IrOOaGel.1.aa.OliloOO •• O,"""OO"'fio060ell-lI- 299

Chapter 2

DISCRETE SIGNALS

41.1 (DiscretE3~ignaLs) Sketch each signal and find its energy or power as appropriate.

"~" ~

(a) x[n] = {6, 4, 2, 2} (b) yIn] = {-3, -2, -1, 0, I}

":I). "

(c) fIn] = {O, 2, 4, 6} (d) gIn] = u[n]- urn - 4]

(e) pIn] = cos{mr/2) (f) qln] = 8(0.5)nu[n]

[Hints and Suggestions: Only pIn] isa power signal. The rest have finite energy.]

(Solution) See the following figure for sketches.

~ .,nf f4 I~

.IJ

(a) x[n] = {6, 4, 2, 2} Energy signal. E =E x2[n] "" 36+ 16 + 4 +4= 60

:IJ. ""

(b) yIn] = {..,-3, -2, -1, O,l} Energy signal, E = Ey2[n] = 9 + 4 +1 + 1 =15

:IJ.

(c) fIn] = {o, 2, 4, 6} Energy signal. E = E f2[n] = 4 + 16 + 36 = 56

(d) gIn] = u[n]- urn - 4] Energy signal. E = E g2[n] = 1+ 1 + 1 + 1 = 4

N-13

(e) pIn] = cos(n1f /2) Period N = 4. Power signal. P = k L p2[n] = i LP2[n] = i(1 + 1) = 0.5

n=O n=O

00 00" 64

(f) q[n] = 8(0.5)nu[n] Energy signal. E =2:: q2[n] = 6464L{0.25)n = 1 -0.25 = 85.3333

n=O n=O

2.2 (Signal Duration) Use examples to argue that the product of a right-sided and a left-sided discretetime signal is always time-limited or identically zero.

[Hints and Suggestions; Select simple signals that either overlap or do not overlap.]

(Solution) The product ofa right-sided and a left-sided discrete-time signal is always time-limited or identically zero.

Example 1: urn - 3] and u[-n]. Their product is zero.

1

2

Chapter 2 Discrete Signals

~ Example 2: u[n·+2] and uI~n]. Their product is { ... ,O,O,l,l,l,O,O, ... }

~

2.3 (Operations) Let xIn] = {6, 4, 2, 2}. Sketch the following signals and find their signal energy.

(a) yIn] = xIn - 2]

(b) fIn] = xIn + 2]

(c) gIn] = xI-n + 2}

(d) hIn} = xI-n - 2}

[Hints and Suggestions: Note that gIn] is a folded version of fIn].] (Solution) See the following figure for sketches.

f[:] ~a) 6 4- _ [61, 4~ (b)!

f4_2_2 22.22

~ n n

I 2 3 I 2 3 4 5 ·2·1 1

.J]t> ...

2 2

n

-1 1 2

~

With xInJ = {6, 4, 2, 2}, we find

(a) yIn] = x[n - 2] = {5, 0, 6, 4, 2, 2} (shift right by 2).

(b) fIn] = xIn + 2] = {6, 4,~, 2} (shift left by 2).

~

(c) gIn] = xI-n + 2} = {2,2,4,6} (fold fIn])

.IJ.

(d) hIn] = xl -n - 2J = {2, 2,4,6,0,0} (fold yIn])

The energy in each signal is E = 36 + 16 + 4 + 4 = 60

2.4 (Operations) Let xIn] = 8(0.5)n(u[n + 1]- u[n - 3]). Sketch the following signals.

(a) yIn] = x[n - 3]

(b) fIn] =x[n+l]

(c) gIn] =xI-n+4]

(d) h[n] = x[-n - 2]

[Hints and Suggestions: Note that x[nJ contains 5 samples (from n = -1 to n = 3). To display the marker for yin] (which starts at n = 2), we include two zeros at n = 0 (the marker) and n = 1.]

.IJ.

(Solution) Note that x[n] = 8(0.5)n(uln+ 1]- u[n - 3]) = {16, 8, 4, 2, I}. Then

.IJ.

(a) yIn] = x[n - 3] = {O, 0, 16, 8, 4, 2, I} (shift right by 3)

(b) fIn] = x[n + 1] = {16,8, ~, 2, I} (shift left by 1)

(c) gIn] = xI-n + 4] = {5, I, 2, 4, 8, I6} (shift left by 4, then fold)

.IJ.

(d) hIn] = xI-n - 2] = {I, 2, 4, 8, 16, O} (shift right by 2, then fold)

Chapter 2 Solutions to Problems

3

2,5 (Energy and Power) Classify the following as energy signals, power signals, or neither and find the energy or power as appropriate.

(a) x[n] = 2"u[-nJ (d) gIn] = cos( mr /2) 1

(g) r[n] = 2"u!n - 1]

n

(j) tIn] = e()+1)m,/4

(b) yIn] = 2"v.[-n - 1] 1

(e) pIn] = -uln - 1]

n

(h) sIn] = ejmr (k) v[n] = ),,/4

(c) !In] = cos(mr)

1

(f) q[n] = -rnu[n - 1]

(i) dIn] = ejm, /2

(1) wIn] = (vfj)" + (.fJ)~"

[Hints and Suggestions: For x[n] and yIn]' 22" = 4" = (O.25)~". Sum this from n = -00 to n = 0 (or n = -1) using a change of variable (n _, -n) in the summation. For pIn], sum 1/n2 over n = 1 to n = 00 using tables. For q[n], the sum of l!n from n = 1 to n = 00 does not converge! For tIn], separate the exponentials. To compute the power for sIn] and dIn], note that Is!n]1 = Id[n] I = 1. For v[n], use) = ejn/2. For win], set ..fJ = ejn/4 and use Euler's relation to convert to a sinusoid.]

(Solution)

o oo 1

(a) x2[n] = 22nu[-n] = (0.25)~"u[-n]. So, E = 2.: (0.25)-n = 2.:(0.25)" = 1 _ 0.25

n=-oo n=O

4 3

1.3333

-1 00

(b) y2[n] = 22nu[-n - 1] = (0.25t71u[-n - 1]. So, E = "\."""' (0.25)-n = "'(0.25)n = 0.~5 =

6 6 1- .25

71=-00 n=1

~ = 0.3333

(c) fin] = cos(mr). Periodic, F = 0.5 and N = 2. x[n] = {I, - I} for one period. 1

So, P = lv Lf2[n] = 0.5(1 + 1) = 1

71=0

(d) gIn] = cos(mr/2}. Periodic, F = 0.25 and N = 4. gIn] = {I,D, -I,D} for one period. 3

So, P = -tv Ll[nj = 0.25(1 + 1) = 0.5

,,=0

1 00 1 1l'2

(e) pIn] = -urn - 1]. So, E = '" 2" = - (from tables)

n 6n 6

n=1

(f) q[n] =)nu[n - 1]. Neither a power signal nor an energy signal (because q2[n] does not decay faster than l!n and I:q2[n] = 1 + ~ + ~ + ... does not converge).

1 00 1 n4

(g) r[n] = 2"u[n - 1]. So, E = L 4 = - (from tables)

n n=1 n 90

(h) sIn] = ejmr. Periodic, F = 0.5 and N = 2 and Is[n]1 = 1. 1

So, P = -tv L Is[nll2 = 0.5(1 + 1) = 1

n=O

4

Chapter 2 Discrete Signals

(i) dIn] = ejn1</2. Periodic, F = 0.25 and N = 4 and Id[n] I = 1. 3

So, P = 1t Ld2[n] = 0.25(1 + 1 + 1 + 1) = 1

n=O

(j) tIn] = e(j+l}nn/4 = emr/4ejmr/4. Neither power nor energy (e"7rj4 = (2.1933)" is a growing exponential) .

(k) v[n] =j"/4 = ejmrj8. Periodic, F= 1~ and N = 16 and Iv[n] I = l. is

So, P = f.r E v2[n] = 1~(16) = 1

"",,0

(1) wIn] = (v1)" + (v1)-" = ejn7rj2 + e-j"7rj2 = 2cos(mr!2). Periodic, F = 0.25 andN = 4 and wInJ = {2, 0, -2, O} for one period.

s

So, P = J., E w2[n] = 0.25(4 + 4) = 2

,,=0

2.6 (Energy and Power) Sketch each of the following signals, classify as an energy signal or power . signal, and find the energy or power as appropriate.

00

(a) x[nJ = E yIn - kNJ, where yIn] = u[n]- urn - 3] and N = 6

k=-oo

00

(b) fIn] = L (2),,-Sk(u[n - 5k]- urn - 5k - 4])

k=-oo

[Hints and Suggestions: The period of x[n] is N = 6. With yIn] = urn] - urn - 3]' one period of x[nJ (starting at n = 0) is {I, 1, 1, 0, 0, O}. The period of fIn] is N = 5. Its one period (starting at n = 0) contains four samples from 2"(u[nJ - urn - 4]) and one trailing zero.]

(Solution) Refer to the sketch.

1(3)

.: Ill .. .'1 f ... 111 .. ~.~

1 23 45 6

l~)

rIll. '_ (I r. ! Ill. ! III :-."

1 2 3 4 5

00

(a) x[n] = L yIn - kN] where yIn] = u[n]- urn - 3] and N = 6. Thus x[n] = {I, 1, 1,0,0,0} for

k=-OQ

one period.

5

So, P = i 2:::>2[nJ = i(l + 1 + 1) = 0.5

,,=0

00

00

(b) fIn] = L (2),,-Sk(u[n - 5k]- urn - 5k - 4]) = L gIn - kN]

k=-oo

k=-oo

where N = 5 and gIn] = 2"(u[n]- urn - 4]).

Chapter 2 Solutions to Problems

5

4

Thus, fIn] = {I, 2, 4, 8,O} for one period and P = t L f2[n] = t(1 + 4 + 16 + 64) = 17

n=O

lJ.

2.7 (Decimation and Interpolation) Let x[n] = {4, 0, 2, -1, 3}. Find and sketch the following

signals and compare their signal energy with the energy in x[n].

(a) The decimated signal dIn] = x[2n]

(b) The zero-iuterpoleted signal fIn] = x[Y,[]

( c) The step-in terpolated signal g [n 1 = x[ Y,[ ] (d) The linearly interpolated signal h[n] = x[~]

[Hints and Suggestions: To get dIn]' retain the samples of x[nJ at n = 0, ±2, ±4, .... Assuming that the interpolated signals will be twice the length of x[n], the last sample will be 0 for J[n], 3 for gIn] and 1.5 (the linearly interpolated value with x[n] = 0, n > 2) for hln].]

(Solution) Let x[n] = {4, 0, ~, -1, 3}. Find and sketch each of the following signals and compare their signal energy with the energy in x[n].

lJ.

(a) d[n] = x [2n] ={4, 2,3}.

lJ.

(b) zero-interpolated fln] = x[~] = {4, 0, 0, 0, 2, 0, - 1, 0, 3, OJ.

lJ.

(c) etep-interpoieied gIn] = x[Y,[] = {4, 4, 0, 0, 2, 2, -I, - 1, 3, 3}.

lJ.

(d) line8J'ly-intel'polated h[n] = x[%] = {4, 2, 0, I, 2, 0.5, - 1, 1, 3, 1.5} (last value interpolated

assuming next sample is zero).

2.8 (Interpolation and Decimation) Let x[n] = 4 tri(n/4). Sketch the following signals and describe

how they differ.

(a) x[~nJ, using zero interpolation followed by decimation (b) x[3'n], using step interpolation followed by decimation (c) x[~n], using decimation followed by zero interpolation (d) x[~n], using decimation followed by step interpolation

(Solution) x[n] = 4tri(n/4) = {O, 1,2, 3,t 3, 2, I, O}

(a) x[n/3] = {O, 0,0,1,0,0,2,0,0,3,0,0, to, 0, 3, 0, 0, 2,0,0,1,0,0,0,0, O} (zero interpolation) x[2n/3] = {0,0,0,2,O,0,tO,0,2,O,O,0,0} (decimation)

(b) xln/3] = {O, 0, 0,1, 1, 1,2,2,2,3,3,3, l, 4, 4, 3,3,3,2,2,2, 1, 1, 1,0,0, O} (step interpolation) lJ.

x[2n/3] = {O,O, 1, 2, 2,3,4,4,3,2,2, 1,0, ° } (decimation)

(c) x[2n] = {O,2,l,2,O} (decimation)

,(I.

x[2n/3] = {O, 0,0,2,0,0,4,0,0,2,0,0,0,0, O} (zero interpolation)

6

Chapter 2 Discrete Signals

JJ

(d) x[2n] = {0,2,4,2,0} (decimation)

x[2n/3] = {0,0,0,2,2,2,t4,4,2,2,2,0,0,0} (step interpolation).

2.9{Fr~ctionaI Delay) Starting with x[n], we can generate the signal x[n - 2] (using a delay of 2) or xl2n - 3] (using a delay of 3 followed by decimation). However, to generate a fractional delay of the

formx[n .; ~] requires a delay, interpolation, and decimation! .

(a) Describe the sequence of operations required to generate x[n ,- ~] from x[n].

(b) Let x[n] = {f, 4, 7, 10, 13}. Sketch x[n] and x[n - n Use linear interpolation where required. (c} G~neralize the results of part (a) togenerateejn-. ~] from x [n].Any restrictions onMand N?

[Hintsand Suggestions: In part (a) the sequence of operations requires interpolation, delay (by 2) and decimation. The interpolation and decimation factors are identical.]

. '(Sol~tion)

(a) x[n]:=::} (interpolate by 3) x[i]---+ (delay by 2) x[ng2] ---+ (decimate by 3) x[n - n .(L

(b) x[n] = {I, 4, 7, 10, 13}.

xl!] = if, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ~6, 1;, O} (linear interpolation).

[n-2J {JJ

x -3- = 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,

2J.(L 26

x[n-s ={O, 2,5,8,11, T}

(c) xln]:=::} (interpolate by N) x[*]---+ (delay by M) x[nl\rM] -+ (decimate by N) x[n - XJ.

26 13 O}

3' 3'

Restriction: M and N must be integers.

2.10 (Symmetry) Sketch each signal and its even and odd parts.

(a) x[nJ = 8(o.5)nu[n] (b) y[nJ = u[nJ (c) fin] = 1 +u[nJ

JJ

(d) g[nJ = u[n]- urn - 4J (e) p[nJ = tri(n33) (f) q[nJ = {6, 4, 2, 2}

[Hints and Suggestions: Confirm the appropriate symmetry for each even part and each odd part. For each evenpart, the sample at n = 0 must equal the original sample value. For each odd part, the sample at n = 0 must equal zero.]

(Solution) See the following figures (not to scale). We find the even part as xe[n] = 0.5(x[n] + x [-nJ) and the odd part as xo[n] = O.5(x[n]- x[-n]) etc.

Signal (a) Even part Odd part

8 g

n

n

123 4

Chapter 2 Solutions to Problems

'7

S' I (b)

I

. .

n 1 2 34 '.

Signal (c)

2 I

I 2 3 4

liZ

1 2 3

Signal (I)

S' I (.f)

.

4

.

n

-1 1 .2

. E .. ven part

.

. .Tr r 1 ... u.u.

... .1.234

Even part

.2

... ]TIl] ;

~ 1234

. ~1/21J 1).. .:

Odd part 112

n

1 2 3 4

n

] 2 3

n

2.11 (Sketching Discrete Signals) Sketch eachof the following Signals: ··(a)x[nJ == T[n + 2]- r[n-2J -4u[n -,-6] (b)y[n] = rect( ~)

(c) J[n]::::rect(n42) (d),9[n] =6tri(n3"4)

. - , .

[Hints and Suggestions: Note that f [n] is a rectangular pulse centered at n = 2 with 5 samples. Also, g[n} is a triangular pulse centered at n =4 with 7 samples (including the zero-valued end samples).)

(Solution) See the following figure for sketches. We note that

(a) x[n] = r[n + 2]- r[n - 2]-c4u[n - 6] is easily sketched as a sum of steps and ramps.

(b) yIn] = rect( ~) is a 7-sample rectangular pulse from n = -3ton=3

(c) f {n] = rect( n42) is a 5-sample rectangular pulse centered atn= 2.

(d) gIn] = 6tri(n3'4) is a 7-sample triangular pulse centered at n = 4 (with end values ofzero).

8

(a)

Chapter 2 Discrete Signals

j(b) lr~) T i i Id)

J U _)J ..'. LU.E illL

-3 1 2 3 1 2 3 4 1 2 3 4 5 6

444

n

123 4

(a) x[n] = e[n]

(c) gin] = tri(n)

2.12 (Sketching Signals) Sketch the following signals and describe how they are related.

(d) h[nJ = sinc(n)

(b) J[n] = rect(n)

(Solution) All represent the same signal because

.I).

x[n] = e[n] = { , 0, 0,1,0,0, }

fin] = rect[n] =! { ,0,0,1, 0, 0, }

gin] = tri[n] = { ,0,0, 1,0,0, }

• .I).

h[n] = smc[n] = { ... ,0,0, 1,0,0, ... }

2.13 (Signal Description) For each signal shown in Figure P2.13,

(a) Write out the numeric sequence, and mark the index n=O by an arrow. (b) Write an expression for each signal using impulse functions.

(c) Write an expression for each signal using steps and/or ramps.

(d) Find the signal energy.

(e) Find the signal power, assuming that the sequence shown repeats itself.

Figure P2.13 Signals for Problem 2.13

[Hints and Suggestions: In part (c), all signals must be turned off (by step functions) and any ramps must be first flattened out (by other ramps) . For example, signal 3 = r{n]- r[n - 5} - 5u[n - 6]. The second term flattens out the first ramp and last term turns the signal off aftern = 5.]

(Soiutioll) Refer to the sketches

x [n} 2 Signal 1 JtlJt Sign;all·2 2t

-3 3 n

n

x[n] Signal

2

x In] Signal 3

-3

n

x[n]

Signal 3

Figure P2.13. Signals for Problem 2.13. (a) Signals as a numeric sequence:

.I).

* {Signal 1:) x[n] = {2,2,2, 2,1,1,1,1,1,1,1, I}

.I).

1111 (Signal 2:) x[n] = {-2, -2,4,4,4, -2, -2}

x[n] 6

2

n

n

n

2

Chapter 2 . Solutions to Problems

9

-IJ.

• (Signal 3:) x[nJ = {O, 1, 2, 3,4, 5}

-IJ.

• (Signal 4:) x[nJ = {6,5,4,3,2,2,2,2,2}

(b) Signal representation by impulses

• (Signal 1:) x[n] = 2(&[n + 3] + 5[n + 2J + 5[n + 1] + &[nD + &[n -IJ + J[n - 2] + ... +&[n - 8] @ (Signal 2:) x[n] = -2&[n + 3]- 2o[n + 2] + 4o[n + IJ + 4&[n] + 4&[n - 1] - 25[n - 2]- 25[n - 3J s (Signal 3:) x[n] = 51n - IJ + 2&[n - 2] +3&[n - 3] +4&[n - 4]+55[n - 5J

@ (Signal 4:) x[n] = 65[n] + 5J[n-l] +4&[n-2J + 35[n - 3]) +2(o[n- 4] +o[n -5] + ... +o[n-8]

(c) Signal representation by steps and ramps:

e (Signal 1:) x[n] = 2u[n + 3] - urn - 1] - urn - 9]

@(Signal 2:) x[n] =-2u[n + 3] + 6u[n + 1] -6u[n - 2] +2u[n - 4J

• (Signal 3:) x[n] = rln) - rln - 5] - 5u[n - 6]

• (SignaI4:) x[n] = 6u[nJ - rln] + r[n - 4]- 2uln -9]

(d) and (e) Signal energy and signal power (ifperiodic)

Signal 1: E = I: x2 [n] = 24 N = 12 P = iT L x2 [n] = i~ = 2

Signal 2: E = I: x2[n] = 64 N = 7 P = -tv L x2[n] = 674 = 9.1429

Signal 3: E = L x2[n] = 55 N = 6 P = J.., I: x2[nJ = 5: = 9.1667

Signal 4: E = L x2[nJ = 106 N = 9 P = -tv Lx2[n]~lg6 = 11.7778

2.14 (Discrete Exponentials) A causal discrete exponential has the form x[n] = anu[n].

(a) Assume that a is real and positive. Pick convenient values fora> 1, a = 1, and a < 1; sketch

x[nJ; and describe the nature of the sketch for each choice of a. .

(b) Assume that a is real and negative. Pick convenient values for a < -1, a = -1, and a > -1; sketch x[n]; and describe the nature of the sketch for each choice of a.

(c) Assume that a is complex and of the form a = Aej8, where A is a positive constant. Pick convenient values for a and for A < 1, A =1, andA > 1; sketch the real part and imaginary part of x[n] for each choice of A; and describe the nature of each sketch.

(d) Assume that a is complex and of the form a = Aej8, whereA is a positive constant. Pick convenient values for a and for A < 1, A = I, and A > 1; sketch the magnitude and imaginary phase of x[n] for each choice of A; and describe the nature of each sketch.

(Solution) (a) a = 0.5 a=l a=2

(0.5)nu[n] = {I, 0.5,0.25,0.125, ... }. This is a decaying exponential,

(l)nu[n] = {I, I, 1, 1, }. This is a unit step (constant).

(2)nu[n] = {I, 2, 4, 8, }. This is a growing exponential.

(b) a = -0.5

(-o.5)nu[n] = {I, -0.5,0.25, -0.125, ... }. This is a decaying exponential.

a=1 a=2

(-l)nu[n] = {I, -1, I, -1, [. This is an alternating step.

(__;2)nu[n] = {I, -2,4, -8, }. This is a growing exponential.

10 Chapter 2 Discrete Signals

(c) 0: = O.5ej8 (O.5ej8)n = (o.5)nejn8. This is an exponentially damped sinusoid.

0: = ej8 (ej8)n = ejn8. This is a sinusoid.

0: = 2ej8 (2ej8)n = (2)ne·in8. This is an exponentially growing sinusoid.

(d) 0: = -O.5ej8 (-O.5ejO)n = (_o.5)neJnO. Damped sinusoid with samples alternating in sign.

0: = eJO (ej8)n = ( _1)nejn8. Sinusoid with samples alternating in sign,

0: = -2eFJ (_2eJO)n = (_2)>iejnO. Growing sinusoid with samples alternating in sign,

2.15 (Signal Representation) The two signalsshown in FigurePz.lf may be expressed as

(a) x[n] = Ao:n(u[n) - urn - NI)

(b) yin) = A cos (21fFn + B)

Find the constants in each expression and then find the signal energy or power as appropriate.

f"l · .. rnl r 2r 2
1 II I f
I n
L JI L I I ~
I ( t n
4- 5 . • ,. '. J I
2 3 -2 -2
Figure P2.15 Signals for Problem 2.15 [Hints and Suggestions: For yIn]' first find the period to compute F. Then, evaluate yIn] at two values of n toget two equations for, sayy[O]anci YII]. These will yield B (from their ratio) and A.]

(Solution) Refer to the sketch.

4lx[nJ

_ ItT n

2345~~~

FigureP2.15.

"f"l r 2r 2
1 1 I I II
I n
L JI L I I I ~
J 1
-2 -2
Signals for Problem 2.15. (a) x[n] = Ao:n(u[n] - urn - N]). From the figure, N = 4. Also x[O] = 4 = A Also, x[2] = 1 = 4(\!2 ,so (\! = 0,5,

(b) yIn] = A cos (21TFn + e). From the figure, N = 6 or F = 1/6. At n = 0 and n = 1, we have

y[O] = 1 = Acos{}

y[l] = -1 = Acos(i + B) = 4- cosB - Af sinO

A V3 . r;; A sin B M

Thus, -1 = 0.5 - -2- sin a or A sm a = v 3. So, A:'COS'e = tan e = v 3.

This gives B = f and A = co;o = 2

Chapter 2 Solutions to Problems

11

2.16 (Discrete-Time Harmonics) Check for the periodicity of the following signals, and compute the common period N if periodic.

(a) x[n] = eos(nn

(c) fIn] = sine n411") - 2cos( n611")

(e) pIn] = 4 - 3sine~1T)

(g) r[n] = cos(~mr) + cos(in) (1) dIn] = ejO.3n1T

(k) v[n] = ejO.3n

(b) yIn] = cos(!§')

(d) gIn] =2cos(n41T)+cos2(nn

(f) q[n] = cos ( 5fz") + cos( 4~1T) (h) sIn] = cos ( 8~1f) cos] ~)

(j) ern] = 2ejO.3n1f + 3ej0.4n1T (1) wIn] = (j)n/2

[Hints and Suggestions: There is no periodicity if F is not a rational fraction for any component. Otherwise, work with the periods and find their LCM. For wIn], note that j = ej1f/z.]

(Solution)

(a) x[n] = cos(0.5mr). So, F = 0.25 = h so periodic with N = 4.

(b) yIn] = cas(0.5n). So, F = 4~' so not periodic (F is not a rational fraction)

(c) fIn] =sin(nn -2eos(nn· So, FI = k, F2 = {z·

So, Nl = 8, N2 = 12. So, periodic with N = LCM(8,12) = 24

(d) gIn] = 2cos(nn + cos2(n4'11') = 2cos{nn + 0.5 + 0.5cos(n27T).

So, FI = k, F2 = t, so Nl = 8, N2 = 4, so periodic with N = LCM(8,4) = 8

(e) pIn] = 4 - 3sine~7f)

Periodic with F = i and N = 8.

(f) q[n] = cos(5rn +coS(4~1f). So, FI = ;4' F2 = 1~ =~.

So, NI = 24, Nz = 9. So, periodic with N = LCM(24,9) = 72

(g) r[n] = eos(8~7T) + cos(83n). Not periodic because F2 = 6~ is not rational.

(h) s[nJ = cos(8~7r) cos(nn = 0.5cos(19S?T) + 0.5eose3;7T). So, FI = i~, F2 = g.

So, N; = 12, N2 = 12. So, periodic with N = 12.

(i) dIn] = ejO.3n7T. So, F = 0.15 = l~O = in. So, periodic with N = 20.

(j) ern] = 2ejO.3mr + 3ej0.4n7T. So, F1'= 0.15 = 1~0 = 230' F2 = 0.2 = t· So, Nl = 20, N2 = 5 and N = LCM(20,5) = 20

(k) v[n] = ejO.3n. So, F = 0;5. Not periodic because F is not rational.

(1) wIn] = (j)n/2 = (ej7T/2)n/2 = ejn?T/4. So, F = k. So, periodic with N = 8.

12

Chapter 2 .. Discrete Signals

2.11 ('1'he Roots of Unity) The Nroots of the equationzN=l can be found by writing it as zN= ej2k1f to give z = ej2k1r/N, k = 0, I, ... 1 N - 1. What is the magnitude and angle ofeach root? The roots

can be displayed as vectors directed from the. origin whose tips lie on a circle. .

(a) What is the length of each vector and the angular spacing between adjacent vectors? Sketch for

N=5 and N=6. ..... . ..

(b) Extend this concept to find the roots of zN = -1 and sketch {or N= 5 and N = 6.

[Hints and Suggestions: In part (b), note thatzN "".,....1 ej1rej2k1r = ej(2k-H)1f.] (Solution) Refer to the sketches.

. A

(a) N=6 (b)

(a) zN = 1 z= ej2k1f/N, k =0, 1, ... ,N -1 with Izl = 1.

N = 5: Angular spacing = ~ = 2;,= 72° with k = 0 at 0°). N = 6: Angular spacing = 2; =2; = 60° (with k = 0 at 0°).

z = ej(2k+l)1f/N, k = 0,1, ... , N -1 with Izl = 1.

N = 5: Angular spacing = ~= 2; = 72° (with k= 0 at 36°). N = 6: Angular spacing = 2; = 2; = 600 (with k = 0 at 30°).

2.18 (Digital Frequency) Set up an expression for each signal, using a digital frequency IFI < 0.5, and another expression using a digital frequency in the range4 < F <5.

(a) x[n] = cos(4~7r)

(b) x[n] =sin( 4~1f) + 3sin(8~1f)

[Hints and Suggestions: First find the digital frequency of each component in the principal range (-0.5 < F .::; 0.5). Then, add 4 or 5 as appropriate toqring each frequency into the required range.]

(Solution)

(a) x[n] = cos(4mr/3). So, F = 4/6 = 2/3. So, F = 2/3 -1 = -1/3.

So, x[n] = cos( -2mI' /3) = cos(2mr /3).

For 4 < F < 5, we have F = -1/3+ 5 = 14/3 and x[n] = cos(28mf/3).

(b) x[n] = sin(4mr/3) + 3 sin(8mr/3). So, Fi = 2/3 = -1/3, F2 = 4/3 = 1/3 So, x[n] = sine -2mf /3) + 3 sin (2n1T /3)

[Note: This can be simplified to x[n] = - sin(2n1T /3) + 3 sin (2n1T /3) = 2 sin(2n1T /3)]

For 4 < F < 5, we have Fi = -1/3 + 5 = 14/3, F2 = 1/3 + 4 = 13/3, and X2 [n] = sin(2Sn1T /3) + 3 sin (26n1T /3)

Chapter 2 Solutions to Problems

13

2.19 (Pigital Smusoids) Find the period N of each signal if periodic. Express each signal using a digital

.. frequency in the principal range (IFI < 0.5) and in the range 3 S; F S; 4. . .

(a) x[nJ = cos('~1r)

(b) x[n] = cosC~1f) + sin(0.5mr)

(c) x[n] = cos(n)

(Solution)

(a) x[n] = cos('~1f). So, F = ~ =} F = r For 3 < F < 4, F = 3 + i = 1:

So, x[nJ = cos(nt) or x[n] = cose9;7l"), 3 < F < 4.

(b) x[n] = cos('~1t") +sin(O.Snn).

So, Fl = i =} Fs = i or Fi = 1:, 3 < F < 4 and F2 = i or F2 = 3 + i = ~, 3 < F < 4 So, x[n] = cos(n37l") + sin(n27l") or x[n] = cos( 19;1f) + sine 13;1f), 3 < F < 4

(c) x[n] = cos(n). So, F = 2; or F = 3 + 2~' 3 < F < 4.

So, x[nJ = cos(n) or x[n] = cos[2n7r(3 + 2; )], 3 < F < 4

2.20 (Sampling and Aliasing) Each of.the following sinusoids is sampled at 8= 100Hz. Determine if aliasing has occurred and set up an expression for each sampled signal using a digital frequency in the principal range (IFI < 0.5).

(a)x(t) = cos(320nt + ~) (b) x(t) = cos(1407ft - ~) (c) xCt) = sin(607ft)

[Hints and Suggestions: Find the frequency /0. If S > 2/0 there is no aliasing and F < 0.5. Otherwise, bring F into the principal range to write the expression for the sampled signaL]

(Solution)

(a) x(t) = cos(3201ft + O.251f). So, /0 = 160 Hz, S = 100 Hz, and F = /0/8 = 1.6.

There is aliasing because F> 0.5 (or 8 < 2/0)'

Now, F = 1.6 = -004, so x[n] = cos ( -O.Snn + 0.25n) = cos(O.8mf - 0.257f).

(b)x(t) = cos(1407ft - 0.251T). So, /0 = 70 Hz, 8 = 100 Hz, and F = /0/8 = 0.7 There is aliasing because F > 0.5 (or 8 < 2/0)'

Now, F = 0.7 = -0.3, so x[n] = cos( -0.6n1T - 0.251T)= cos(0.6n1T + 0.251f).

(c) x(t) = sin(601Tt). So, /0 = 30 Hz, 8 = 100 Hz, and F = /0/8 =0.3

There is no aliasing because F < 0.5 (or 8 >2/0). So, x[n] = sin(O,6n1T).

2,21 (Aliasing and Signal Reconstruction) The signal x(t) = cos(3201Tt + ~) is sampled at 100 Hz,

and the sampled signal x[n] is reconstructed at 200 Hz to recover the analog signal xr(t).

(a) Has aliasing occurred? What is the period N and the digital frequencyF' ofx[n]? (b) How many full periods of x(t) are required to generate one period of x[n]?

(c) What is the analog frequency of the recovered signal xr(t)?

(d) Write expressions for x[n] (using IFI < 0.5) and for xr(t).

14

Chapter 2 Discrete Signals

[Hints and Suggestions: For part (b), if the digital frequency is expressed as F = kjN whereN is the period and k is an integer, it takes k full cycles of the analog sinusoid to get N samples of the sampled signal. In part (c), the frequency of the reconstructed signal is found from the aliased frequency in the principal range.]

(Solution) x(t) = cos(320rrt + t) with S = 100 Hz and SR = 200 Hz. (a) Aliasing has occurred. fo = 160 Hz. So, Fo = ig~ = ~. So, N = 5.

(b) 8 full periods of xCt) generate one period (5 samples) of x[n].

(c) The digital frequency in the principal range is Fo = 1.6 =} Fo = -0.4.

The analog frequency of the recovered signal xr(t) is fa = SFo = 200( -0.4) = -80 Hz

(d) x[n] = cos] -0.8mr + t) = cos(0.8mr - ~)

xrCt) = cos ( -1607ft + t) = cos(160rrt - %).

2.22 (Digital Pitch Shifting) One way to accomplish pitch shifting is to play back (or reconstruct) a sampled signal at a different sampling rate. Let the analog signal x(t) = sin(158007ft + 0.257f) be sampled at a sampling rate of 8 kHz.

(a) Find its sampled representation with digital frequency IFI < 0.5.

(b) What frequencies are heard if the signal is reconstructed at a rate of 4 kHz? ( c) . What frequencies are heard if the signal is reconstructed at a rate of 8 kHz? (d) What frequencies are heard if the signal is reconstructed at a rate of 20 kHz?

[Hints and Suggestions: The frequency of the reconstructed signal is found from the aliased digital frequency in the principal range and the appropriate reconstruction rate.]

(Solution)

(a) x(t) = sin(158001ft+0.257f) and S = 8000 Hz. So, fo = 7900 Hz and Fo = ~6~~ = ~6 =} Fo = '8J.

SO, x[n] = sine - 2;0" + 0.25rr) = - sine;o'1l' - 0.257f).

(b) If SR = 4 kHz, the reconstructed frequency is FOSR = _4~~O = 50 Hz (i.e., 50 Hz).

(c) If SR = 8 kHz, the reconstructed frequency is FOSR = _8~~O = -100 Hz (i.e., 100 Hz). (d) If SR = 20 kHz, the reconstructed frequency is FoSR = _208~0 = -250 Hz (i.e., 250 Hz).

2.23 (Discrete-Time Chirp Signals) Consider the signal x(t) = cos[(,b(t)], where (,b(t) = o:t2. Show that its instantaneous frequency fi(t) = 21,,(,bI(t) varies linearly with time.

(a) Choose a: such that the frequency varies from 0 Hz to 2 Hz in 10 seconds, and generate the sampled signal x[n] from x(t), using a sampling rate of S = 4 Hz.

(b) It is claimed that, unlike x(t), the signal x[n] isperiodic. Verify this claim, using the condition for periodicity (x[n] = x[n + N]), and determine the period N of x[n].

(c) The signal yIn] = cos(rrFon2jM), n = 0, 1, ... , M -1, describes an M-sample chirp whose digital frequency varies linearly from 0 to Fo. What is the period of yIn] if Po = 0.25 and M = 8?

[Hints and Suggestions: In part (b), if x[n] = cos(.6n2), periodicity requires x[n] = x[n + N] or cos«(3n2) = cos[.8( n2 + 2nN + N2)]. Thus 2nN.8 = 2rl11r and N2.8 = 2k1f where m and k are integers. Satisfy these conditions for the smallest integer N.]

(Solution) xCt) = cos[¢(t)] = cos(a:t2). So, fi(t) = 2~¢I(t) = f!t. This varies linearly with t.

Chapter 2 Solutions to Problems

15

(a) If the frequency varies from 0 to 2 Hz in 10 seconds, % = 120' So, a = 0.21f.

Now, 8 = 4 Hz, so t = nts = 17,/8 and x[nJ = cos(an2/82) = cos( 'lf8~2.

(b) x[n + N] = cos[:a(n + N?] = cos[8~(n2 + 2nN + N2)].

So, for x[n] = x[n + N], we require :a = m and ~~ = 2k (where N, m and k are integers that make the last two terms integer multiples of 21/-). The smallest N that satisfies these results is N = 80. So, x[n] is periodic with period N = 80.

(c) yIn] = cos(1fFon?/M). With Fa = 0.25 and M = 8, yIn] = cosG2n2). Following part (b), yIn] is periodic with period N = 32.

2.24 (Time Constant) For exponentially decaying discrete signals, the time constant is a measure of how fast a signal decays. The 60-dB time constant describes the (integer) number of samples it takes for the signal level to decay by a factor of 1000. (or 20 log 1000 = 60 dB).

(a) Let x[n] = (0.5tu[n]. Compute its 60-dB time constant and 40-dB time constant.

(b) Compute the time constant in seconds if the discrete-time signal is derived from an analog signal sampled at 1 kHz.

(Solution)

(a) x[n] = (0.5)nu[n]. So, x[O] = 1. The 60-dB time constant is found from (0.5)n = 0.001 and gives nlog(O.5) = log(O.OOl) or n = 9.9658 :=::i 10. The 40-dB time constant is found from (0.5)n = 0.01 and gives nlog(0.5) = log(O.01) or n = 6.6439:=::i 7.

(b) With 8 = 1 kHz, the 60-dB and 40-dB time constants are 10 ms and 7 ms, respectively.

2.25 (Signal Delay) The delay D of a discrete-time energy signal x[n] is defined by

00

L kx2[k]

D = k=-oo 00

L x2[k]

k=-oo JJ.

(a) Verify that the delay of the symmetric sequence x [17,] = {4, 3, 2,1,0,1,2,3, 4} is zero.

(b) Compute the delay of the signals gIn] = x[n -1] and h[nJ = x[n - 2J.

(c) What is the delay of the signal yIn] = 1.5(O.5)nu[n]- 25[n]?

[Hints and Suggestions: For part (c), compute the summations required in the expression for the delay by using tables and the fact that yIn] = -0.5 for 17, = 0 and yIn] = 1.5(0.5)n for n ~ 1.]

(Solution)

1.'

(a) x[nJ={4,3,2,1,O,1,2,3,4}, -4$k$4

4

L kx2[kJ

We compute D = ki4x2[kJ

o

= 60 = O.

Hi

Chapter 2 Discrete Signals

.!J.

(b) gIn] = {4, 3, 2, 1,0, 1, 2, 3,4}, - 3:=; k:=; 5

5

I: kg2[k]

We compute D = k=i:3g2[k] = ~g = 1.

. .!J.

h[n] = {4, 3, 2,1,0,1,2,3, 4}, - 2 :=; k :=; 6

6

I:: kh2[kJ

We compute D = k=i:\2 [k] = lioo = 2,

(c) yIn] = 1.5(0.5)nu[n] - 26[n]. Since y[O] = -O,5andy[nJ = 1.5(0.5)n, n 2: 1, we compute P'7Lh2[k] = (-0.5)2+(L5fL~1(O,25)k.=O.25+ (1.5)21~'~~25 = 1

_ ,"". 2r ~]_ 2 2,",,00. k _ 2. (0,25) _

Q - L__, khlk - O( -0.5) + (1.5) Lk=l k(O.25)-,-{1.5) (1 .; 0.25)2 __ 1

So, the delay is D = ~ = 1,

2,26 (Periodicity) It is claimed that the sum of an absolutely summable signal x[n] and its shifted (by multiples of N) replicas is a periodic signal xp[n] with period N. Verify this claim by sketching the following and, for each case, compute the power in the resulting periodic signal xp [n] and compare the sum and energy of one period of xp[n] with the sum and energy of x[n].

(a) The sum of x[n] = tri(n/3) and its replicas shifted by N = 7 (b) The sum of x[nJ = tri(n/3) and its replicas shifted by N = 6 (c) The sum of x[n] = tri(n/3) and its replicas shiftedbyN = 5 (d) The sum of x[n] = tri(n/3) and its replicas shifted by N = 4 (e) The sum of x[n] = tri(n/3) and its replicas shifted by N = 3

.IJ.

(Solution) x[n] = tri(n/3) = {O, ~, ~, 1, ~, !, O}. We have L x[n] = 3 and E = Lx2ln] = 199.

Refer to the sketches for the periodic extensions.

... rlj(~1\BN=1 r 11 II! ", ... r Ijrll,N-6111 11 r .•

.Lr..IL_t..L __ I. .Ll.l.l.Ll i.r l.l,

1234567 123456

j(C) N=5 j(d) N=4 jljlrl/r=3 1 1

... I II If, II! r llll I "~JJI . 1'1 I IllII11':;'IIJ Lillil

12345 1234 123

(a) For N = 7, we have LXpln] = 3, e, = 199 and P = ~~ (b) For N = 6, we have Lxp[nJ = 3, Ep = 1: and P = ~~ (c) For N = 5, we have I>p[n] = 3, Ep = ~ and P = !~

Chapter 2 Solutions to Problems

17

(d) For N = 4, we have Exp[n] = 3, Ep = f and P = ;2 (e) For N = 3, we have Exp[n] = 3, Ep = 3 and P = 1

2.27 (Periodic Extension) The sum of an absolutely sununable signal x[n} and its shifted (by multiples

of N) replicas is called the periodic extension of x[nJ with period N. .

(a) Show that one period of the periodic extension of the signal x[n] = anu[n] with periodN is

an

yIn] ~ 1 _ aN ' 0::; n ::; N - 1

(b) .II()¥.'do(ls .thesum ofon(l period of the periodic extensionj, In] eOlllP#re wi ththe sum of~[nJ? (c) With a = 0.5 and N= 3, compute the signal energy in x[n] and the signal power in yIn].

[Hints and Suggestions: For one period (n = 0 to n = N -1), only x[nJalld the tailsofthereplicas to its left contribute. So, find the sum of x[n + kN] = an+kN only from k = 0 to k =oo.J

(Solutioll)

(a) x[n] = anu[n]. So, itsperiodicextension with period N is

~ .~ = n

yin] = 2: an-kNu[n :--kN] =2: an+kN = an 2:) aN)k = 1 ~ aN

k=-= k=O k=O

x[n]

Thus,y[n] = 1 _ aN ,0::; n ::; N - 1.

(b)

The sum of x[n] equals the one- period sum of yIn]:

N-l an (1) (1 - aN) 1

~ 1 - aN = 1 '- aN 1 - a = 1 - a

~ 1

~an=_ L....J I-a

n=O

(05)n (c) For a = 0.5 and N = 3, x[nJ = (O.5)nu[n] and yin] = 1 _ (0.5)3'

The signal energy in x[n] is E = f)0.25t = ~ = 1.3333

n=O

The signal power in yin] is

2

P = k Ly2[n] = * = 0.5714

n=O

2.28 (Signal Norms) Norms provide a measure of the size of a signal. The p-norm, or Holder-norm, Ilxllp for discrete signals is defined by Ilxllp = (2::: IxIP)l/P, where 0 < p < 00 is a positive integer. For p = 00, we also definellx!l~asthe peak absolute value Ixlmax•

(a) Let x[n] = {3, -j4, 3 + j4}, Find Hxlh, Ilxlb, and IIxll~.

(b) What is the significance of each of these norms?

(Solution)

IS

(a) x[n] = {3, -j4, 3 + j4}. So Ix[nll = {3, 4, 5}. Thus, IIxll! = I:: Ix[nll = 3 + 4 + 5 = 12

IIxll2 = (I:: Ix[nW) 1/2 = (9 + 16 + 25) 1/2 = J50 = 7.0711 Ilxll<XJ = max(jx[nJl) = 5.

(b) The norm IIxlll signifies the absolute area.

The norm IIxl12 is similar to the rms value (and related to the signal power). The norm Ilxll<XJ is the peak absolute deviation from zero.

I COMPUTATION AND DESIGN

2.29 (Discret e Signals) For each part, plot the signals x[n] and yIn] over ~10 ~ n ~ lOand compare.

(a) .I[n] = urn + 4] - urn - 4] + 28[n + 6] - 8[n - 3] (b) x[n] = r[n + 6] - r[n + 3] - r[n - 3] + r[n - 6] (c) x[nJ= rect( ~) - rect(ns3)

(d) x[n] = 6 tri( %) - 3 tri( 1})

yIn] = x[-n-4] yIn] = x[n - 4] yIn] = x[n + 4] yIn] = x[-n + 4]

(Solution) Uses the author's routines ustep, uramp, urect, udelta, tri, operate, dtplot

%PROBLEM 3.29

%PART (a) n=~10:10jx~ustep(n+4)-ustep(n-4)+2*udelta(n+6)-udelta(n-3);ax=[-15 15 0 3]; [ny ,y] =operate(n,x, -1, -4) j subplot (2 ,1,1) ,dtplot (n .x , '0;) ,axis (ax) •

subplot (2,1,2) ,dtplot (ny ,y,'o') ,axis (ax) ,pause .

%PART (b) .

x=uramp(n+6)-uramp(n+3)-uramp(n-3)+uramp(n-6)jax=[-15 15 0 4]; [ny,y]=operate(n,x,1,-4);subplotC2,1,1),dtplot(n,x,'0') ,axis (ax) , subplot(2,1,2),dtplot(ny,y,;o') ,axis(ax) ,pause

%PART (c)

x"urect (n/l0)-urect «n-3)/6) ;ax=[-15 15 02]; [ny,y]=operate(n,x,1.4);subplotC2,l,1),dtplot(n,x,'o'),axis (ax) , subplot (2, 1 ,2) ,dtplot (ny ,y,'o') ,axis (ax) ,pause

·%PART(d)

x ... (i*trHn/6)-3*triCn/3); ax= [-15 15 0 4]; [ny,y]=operate(n,x,-i,4);subplot(2,1,1),dtplot(n,x,'o') ,axis (ax) , subplot(2,1,2),dtplot(ny,y,'o'),axis(ax)

You could also use the routine dtsiggui. The plot shown is for part (d)

19

• •• ~ ••• I ••• : •••••••••••• : ••• , ••••••••

· .

···········;············1'··········· .,

· .

• ••• L •••••• ~ •••••••••••• ~ •••••••••••

· ~ , . , .

· .

• •• ~ I •• " .••• : ••••• I •••••• : •••••••••

· .

··········'t············.·········

·::·',i-:-·::.-.".-.'-.'-,·-·-'.-:'.- "', . -.,.,- .. -,.:":"'.--'

2.30 (Signal Interpolation) Let h[n] =sin(mr/3), Os n S 10. Plot the signal h[n]. Use this to generate and plot the zero-interpoleted, step-interpolated, and linearly interpolated signals assuming interpolation by 3.

(Solution) Uses the author's routines dtplot, interpol

%PROBLEM 3.30 n"O:10;h=sin(n*pi/3);dtplot(n,h,'o') ,pause

hz=interpolCh,'z' ,3);L=length(hz)-1;dtplot(0:L,hz,'o') ,pause hz=interpolCh,'c' ,3);dtplot(0:L,hz,'o'),pause

hz=interpol (h ," l' ,3) ; dtplot (0: L,hz,' 0 ')

%Zero interp %Step interp %Linear interp

2.31 (Discrete Exponentials) A causal discrete exponential may be expressed as x[nJ = anu[n], where the nature of a dictates the form of x[nJ. Plot the following over 0 :S 17, :s; 40 and comment on the nature of each plot.

(a) The signal x[n] for a = 1.2, a = 1, and a = O.S.

20 Chapter 2 Discrete Signals

(b) The signal x[nJ for 0: = -1.2, 0: = -I, and a: = -0.8.

.. .• (c). The real part and imaginaryparts ofx[nJ for 0: = Aej1f/4, withA = 1.2, A= 1,. and A ==0.8 -. ··(d)Tllemagnitude and ph8£e of x[nJ fora: = Ae;'1f/4, vvithA=1.2,A 1, and A = 0,8.

(Solution) Uses the author's routine dtplot

%PROBLEM 3.31 Il==O:40j a=L, 2; x=a. "n ; subplot (3,1,1) ,dtplot (rr.x , '0') a=1; x=a" "n ; subplot (3,1,2) ,dtplot (n .x , '0')

a ... O,8jx=a. "n ; subplot (3, 1 ,3) ,dtplot(n,x,' 0') .pause %PART (b)

{a=.,1.2;x=a. ~nisubplot(3,t. 1) ,dtplot(n,x, '0') i-::

• ···a='"};~=a.~n;subplot(3.1,2),dtplot(n.x.)0') ... ·ii· .•. ·· .

• ·.···a .... O.$ ix ... a,.~n;f;upplot(3, 1,3},dtplot(n,x > ' 0' ),pause ..•..•..•.

%PART(c) . . . .. . . .

/a"'J.2*exp(j*pij4);x,;a."n; · .. ··iiii ...

subplot (3.2,1) ,dtplot (n ,real (x) , , . ') ,subplot (3,2,2) ,dtl'lot<n,im<1g(x},'.')

Cl.;1,9*exp(j*pi/4)jx=a. "n; ·\>i<·.·.··.··.·.··· .• • •. ., •.• ·· •. .. -. ·· .

subplot (3, 2.3) ,dtplot (n,real(x) , > • ,) ,subplot (3.2,4) ,dtplot<n,imag(x) .'.')

a ... O.8'i'expej*pi/4) jx=a. ~nii .... .

subplot (:3,2, 5) ,dtplot(n,real(x),'. ') ,subplot(3,2,6) ,dtp:tot(n,imag(x), '),pause

%PART(d) .. .. .

.a=L2*exp(j*pi/4)jx=a. "n; .••••...•......••••. ···ii •..

subplot(3,2,l) ,dtplot(n,abs(x),).», subplot(3,2.2) ,dtplo"t;(n,aIlg1e(x),J.')

a=LO*expej*pi/4) ;x=a. "n ; ..••....•........•.•.....•..•.•............•....................

• subplot(3,2.3),dtplot(n,abs(x),'.') ,subplot(3~2~4),dtplot(n'aIlgle(x),', ')

Cl,==().B*e:lCp(j*pi/4) ;x=a.~n; .. ... . ··i· ..iii<·. ... . ..

flllbpJ,.ot. (3,2,p).dtplot(Il.abs (x) .: .~.') ,subplot(3,2.6),ptpJ,.0t:(Il,angleex),'.')

2~32(Di.screte-Time Sinusoids) Which of the following signals are periodic and with what period? Plot . . eachsignalover ..,..10:::; n :S 30. Do the plots confirm yourexpectations?

(a) x[nJ = 2cos(n21f) + 5sin(~1r) (c) x[n] = cos(O.5n)

(b) x[n] = 2cos(nn sin(nn

(d) x[n] = 5 sine'; + :f) -5cos( ns1r .. ,"," t)

(Solution) Uses the author's routine dtplot

%PROBLEM 3.32 n=-10:30;

xl .. 2*cos(n*pi/2)+5*sin(n*pi/5);subplot(2,2,1),dtplot(n,xl,'.') x2==2*cos(n*pi/2) . *sin(n*pi/3) jsubplot (2,2,2) ,dtplot (n,x2, , . ')

·xp 2*cos(n/2) isubplot (2,2,3) ,dtplot(n,x3,'.')

.x4 5*sin(Mpi/8+0.25*pi)-5*cos(n*pi/8-0.25*pi)i

subplot(2,2,4) ,dtplot(n,x4,'.') %Zero (Note the y-scale)

%Period N=20 %Period N ... 12 %N ot peri odi c

ChapterZ Solutions to Problems

21

2.33 {Complex- Valued Signals) A complex-valued signal x[n] requires two plots for a complete descrip-

. tionin one of two forms-=the magnitude and phase VS. n or the real part vs, -n. andirrUlginary part

. ' . -. - .

vs. n.

(a) Let x[n] = d, 1 + j, - j2, 2 - j2, - 4}. Sketch each form for x[n] by hand.

(b) Let x[n] = e-jO.3nrr. Use MATLAB to plot each form over -3050 nS 30. Isx[n] periodic? If so, can you identify its period from the MATLAB plots? From which form, and how?

(Solution) x[n] = {2, 1 + i. - j2, 2 - j2, - 4} = {2, V2L45°, 2L - 900, 2V2L - 45°, 4L1800}

%PROBLEM 3.33 Uses the author's routine dtplot n=-30:30jx=exp(-j*0.3*n*pi);axis([-30 30 -1 1]) subplot(2,2,1),dtplot(n,real(x»,axis([-30 30 -1 1]), subplot(2,2,2),dtplot(n,imag(x»,axis([-30 30 -1 1])

s\lbplot(2,2,3).dtplot(n,abs(x»,axis([-30 30 0 1J) subplot(2,2,4),dtplot(n,angle(x»,axis([-30 30 -pi pi])

%All (except magnitude) allow the period to be determined. N=20

2.34 (Complex Exponentials) Let x[n] = 5V2ej(¥-*). Plot the following signals and, for each case, derive analytic expressions for the signals plotted and compare with your plots -. Is the signal x[n] periodic? What is the period N? Which plots allow you determine the period of x[n]?

(a) The real part and imaginary part of x[n] over -20 S n 50 20

(b) The magnitude and phase of x[n] over -20 S n :::; 20

(c) The sum of the real and imaginary parts over -20 S n S 20

(d) The difference of the real and imaginary parts over -20 :::; n :::; 20

(Solution) x[n] = 5v'2ej( fn-f).

Realpart: XT = 5V2cos(nf)?r - 0.25w}, Imaginary part: Xi = 5V2sin(ng?r - 0.2571') Magnitude: Xm = 5-/2, Phase: xp = ng?r - 0.257f

XT + Xi = lOsin( ng1T), XT - Xi = 10 cos( ng1T)

%PROBLEM 3.34 Uses the author's routine dtplot n=-20:20;x=5*sqrt(2)*expej*(n*(pi!9)-pi/4»)j %PART (a)

subplot(2,2,1),dtplot(n,real(x) ,'0') subplot(2,2,2),dtplot(n,imag(x),'o')

%PART (b)

subplot(2,2,3),dtplot(n,abs(x).'o') subplot(2,2,4),dtplot(n,angle(x),'o').pause %PART (c) subplot(2,1,1),dtplot(n,real(x)+imag(x),'o') subplot (2",1,2) , dtplot (n , real (x) - imag (x) , ' 0')

%All plots (except magnitude) allow the period to be determined. N=18

22

Chapter 2 Discrete Signals

2.35 (Complex Exponentials) Let x[ nJ = ( /.n n + (-In -n . Plot the following signals and, for each case, derive analytic expressions for the sequences plotted and compare with your plots. Is the signal x[nJ periodic? What is the period N? Which plots allow you determine the period of x[nJ?

(a) The real part and imaginary part ofx[nJ over -20 :S n :S20

(b) The magnitude and phase of x[nJover -20 :S n :S 20

(Solution) x[nJ = (v'J)n + (/J)~~n = ejmr/4 + e-jn7f/4 = 2cos(mrj4).

%PROBLEM 3.34 Uses the author's routine c;ltplQt n=-20: 20; j =sqrt; C -1) ; x=sqrt (j) . "n+sqrf (j) . ~(-n) ;

%PART (a) ... .

subplot (2.2,1) ,dtplot (n,reaHx) , '0') subplot(2.2,2),dtplot(n,imag(x),'o') %PART(b)

subplot(2.2,3),dtpl,ot(n,abs(x),'o') subplot(2,2,4).dtplot(n.angle(x).'o')

%Thereal part and angle allow the period to be determined. N=5

2.36 (Discrete-Time Chirp Signals) An N-sarnplechirp signalx[n] whose digital frequency varies linearly from Fo to Fi is described by

x[n] = cos [27f(Fon+ Ft2~Fon2)] ,

n=O,l, ... ,N-l

(a) Generate and plot 800 samples of a chirp signal x whose digital frequency varies from F = 0 to F = 0.5. Using the MATLAB based routine timefreq (from the author's website), observe how the frequency of x varies linearly with time.

(b) Generate and plot 800 samples of a chirp signal x whose digital frequency varies from F = 0 to F = 1. Is the frequency always increasing? If not, what is the likely explanation?

. [( H - Fo 2)]

(Solutron) x[n] = cos 2rr Fan + 2N n

n = 0,1, ... N-1

%PROBLEM 3.36 Uses the author'S routine timefreq N~800;n;O:N-1;FO=O;F1=O.5; x=cos(2*pi*(n*FO+O.5*n.*n*(F1-FO)!N));

timefreq(x);pause %Frequency increases linearly from F=O to F=O.5 FO=0;F1"'1 ;

x=cos(2*pi*(n*FO+O.5*n.*n*CF1-FO)/N));

timefreq(x); %Frequeucy increases up to F=O.5, then decreases (aliasing)

Chapter 2 Solutions to Problems

23

2.37 (Chirp Signals) It is claimed that the chirp signal x[11,] = cos(7f11,2/6) is periodic (unlike the analog chirp signal x{t) = cos(7rt2/6)). Plot x[11,] over 0::; 11,::; 20. Does x[11,] appear periodic? If so, can you identify the period N? Justify your results by trying to find an integer N such thatx[n] "'" x[n + N]

(the basis for periodicity).· . .

(Solution) Uses the author's routine dtplot

For periodicity, x[n] = cos(7fn2/6) = x[n + Nj= cos[?T(n + N)2/6] = cos[7f(n2 + 2nN +N2)/6].

7f{2nN + N2) ..

So, . ·6 = 2k?T or 2nN+ N2= 12k. This is satisfied for N=6.

%PROBLEM 3.37 n:;;0:20;x"cos(pi*n.*n/6);dtplot(n,x,'o') %Period N=6

2,3S·(Signal AVeragi~g) -. Extractionofsignalsfroll1noise is an importantsignal-processingapplication. . . Signal averaging relies on aver aging the results of many runs. The noise tends to average out to zero,

and the signal quality or signal~to-l1oise ratio (SNR) improves. . .

(a) Generate samples of the sinusqid x(t} = sin(800?Tt) sampled atS =:8192 Hz for2 seconds. The sampling rate is chosen sothatyou may also listen to the signal if your machineallows, .

(b) Create a noisy signal s [n]by adding x[n] tosamples of uniforIl1lydistribllteqnoise s~chthat s [n] has an SNRof10 dB. Compare the noisy signal with the original and compute the actual SNR of the noisy signal.

(c) Sum the signal sIn] 64 times and average the result to obtain the signal sarn]. Compare the averaged signal Sa In], the noisy signal s[n], and the original signal x[n]. Compute theSNR of the averaged signal xa[n]. Is there an improvement in the SNR? Do you notice any (visual and audible) improvement? Should you?

(d) Create the averaged result xb[n] of 64 different noisy signals and compare the averaged signal xb[n] with the original signal x[n]. Compute the SNR of the averaged signalJ:b!n]. Is there an improvement in the SNR? Do you notieeany (visual and/or audible) improvement? Explain how

the signal'xb[n] differs from xa[nl. . . . .

(e) The reduction in SNR is a function of the noise distribution. Generate averaged signals, using different noise distributions (such as Gaussian noise) and comment on the results.

(Solution) Uses the author's routine randist

%PROBLEM 3.38 S=8192;ts=1/S;t=0:ts:2; ax",[OO.01 -1. 5 1. 5] ; x",sin(800*pi*t);

%PART (b)

% Time array

% Plot for 0.01 5 for .all signals % Pure sinusoid

xn=randist(x,>uni' ,0);

snr:;;10; A=std(x)/std(xn)/(10n(snr/20)); y=A*xn;zn=x+y;

subplot (3,1,1) ,plot(t .x) ,axis(ax) subplot(3.1,2),plot(t,y),axis(ax) subplot(3,l,3) ,plot(t,zn).axis(ax) ,pause SNR=10*log10(sum(x.*x)/sum(y.*y)) % Compute

% uniform noise (mlilan=O) % Desired SNR

% Compute!

% Generate noisy signal

actual SNR

Chapter 2 Discrete Signals

24

%PARTo(c)

z=O;fo;r n=1:64; % Initialize z and start loop

z=~+x+y; % Sum

if n==16 , a16=z/16; end % Save average of 16 runs

end % End of summing 64-runs

a64'-""z/64; % Average of 64 runs

subplot (3, 1 ,1) ,plot (t, zn) ,axis(ax) % Plot noisy signal

subplot(3,1,2),plot(t,a16),axis(ax)% and 16-runaverage

subplot(3, 1,3) .plot(t ,(64) ,axis(ax) .pause % and 64-run (not any better)

%PART . (d)

·z"O;f~rD.=1:64; % Initializez and start loop 2:=z+~+A*r~dist(x>'uni',O);% :Keep sUlDlllingeachrun .

ifn", = 16 ,a16,,:,z/16; end %~aveaveragl;!of16runs

end % End of suma ing 64-rllns

a,$4=z/64 ; % Average of i64runf>

sUbplot(3,i,1},plot(t ,zn),axis (<LX) % P:Lot noisysign<d

subplot(3,i,2),plot(t>a16»axj,s(ax)%~d16-rUIlavel:"age subplot(3,l,~),pl()t(t,~64) .axis(ax) ,pause % ~d64-run(muchbetter)

%PART (e)

xll=randist(x 'nor' 0)'

.. :::.' -' .. :' '_ _ - _, , ",' .f _. ,

snr=10;

A':'std(x) /std(xn) / (lOft (snr/20»; y,,:,A*xnj SNR2=10*log10(sum(x.*x)/sum(y.*y)

z=O: forn=i :64' . ...

.'" _.' . ', __ J

z=z+x+A*randif>t ex, 'nor' ,0) ;

ifn==16, a16=z/16; end

end

a64=z/64;

subplot(3,l,1) ,plot(t,zn) ,axis (ax) subplot(3.1,2),plot(t,a16).axis(ax) subplot(3,1,3),plot(t,a64) ,axis (ax)

% Gaussian Iloise (mean=O) % DesiredSNR.· .

% Computl;! A

% Compute actual SNR

% Ini tializez and start loop % Keep summing each run

% Save average oi 16 runs % End of summing 64~runs % Average of 64 runs

% Plot noisy signal % and i6-run average

% and 64-run (much better)

2.39 (The Central Limit Theorem) Thecentral Iimit theorem asserts that the sum of independent noise distributions tends to a Gaussian distribution as the number N of distributions in the sum increases. In fact, one way to generate a random signal with a Gaussian distribution is to add many (typically 6

to 12) uniformly distributed signals. . .

(a) Generate the sum of uniformly distributed random signals using N = 2, N =6, and N ""'. 12 and plot the histograms of each .SUUL Does the histogram begin to take on a Gaussian shape as N

increases? Comment on the shape of the histogram for N = 2. .. . .

(b) Generate the sum of random signals with different distributions using N = 6 and N= 12. Does the central limit theorem appear to hold evenwhen the distributions are not identical (as long

as you select a large enough NJ? Comment on the physical significance of this result. .

Chapter 2 Solutions to Problems

25

(Solution) Uses the author's routine randist

1.PROBLEM 3; 39

S=OjN=2;x=randist(500,'uni' ,O);for k=1;2,S=S+randist(500,'uni' ,O)jend %ForN=2, should ideally be triangular (convolution of uniform distr,ibutiqns) subplot (2, 2,1) ,hist(x, 20) ,subplot(2, 2 ,2) ,hist (S ,20) ,pause

S",O; for k=L: 6 ,S=S+randist (500, 'uni) ,0) ; end .

subplot(2,2,l),hist(x,20),subplot(2,2,2),hist(S,20)

S"'O; for k .. l: 12,S",S+randist (500, 'uni' ,0) i end subplot(2,2,3),hist(x,20),subplot(2,2,4),hist(S,20),pause

,%PART (b) .

S~O;for k=1;6,S=S+randist(500,'exp');end % Exponential distribution subplot(2,2,1),hist(x,20),subplot(2,2,2),hist(S,20)

S=O;for k"'1:12,S=S+randist(500,'exp');end subplot(2,2,3),hist(x,20),subplot(2,2,4),hist(S,20)

2.40 (Music Synthesis I) A musical composition is a combination of notes, or signals, at various frequendes. An octave covers a range of frequencies from fa to 2fo. In the western musical scale, there are 12 notes per octave, logarithmicallyequispaced. The frequencies of the notes from}o to2focorrespond to

f = 2k/12 fo

k = 0,1,2, ... , 11

The 12 notes are as follows (the ~ and" stand for sharp and flat, and each pair of notes. in parentheses has the same frequency):

An Example: Raga Malkauns: In Indian classical music, a rllga is a musical composition based on an ascending and descending scale. The notes and their order form the musical alphabet and grammar from which the performer constructs musical passages, using only the notes allowed, The performance of a raga can last from a few minutes to an hour or more! Raga maikauns is a pentatonic raga (with

five notes) and the following scales: . .... . .

Ascending: D F G Bb C D Descending; C B" G F D

The final note in each scale is held twice as long as the rest. To synthesize this scale in MATLAB, we start with a frequency fo corresponding to the first note D and go up in frequency to get the notes in thea,scending scale; when we reach the note D, which is an octave higher, we go down in frequency to getthe notes in the descending scale. Here is a MATLABcodeJragment.

fO"340; d=fO;

f ... fO*(2~(3/12»); g"fO*(2~(5/12»); bf=fO*(2~(8/12)); c=fO*(2~(10/12»;

d2=2*d;

% Pick a frequency and the note D % The notes F and G

% The notes B(flat) and C

% The note D (an octave higher)

Generate sampled sinusoids at these frequencies, using an appropriate sampling rate (say, 8192 Hz); concatenate them, assuming silent passages between each note; and play the resulting signal, using the MATLAB command sound. Use the following MATLAB code fragment as a guide:

26

Chapter 2 Discrete Signals.

ts=1/8192; t"O:ts:O.4; sl=O*(0:ts:0.1)j s2=0*(0;ts;O.05); tl .. O:ts:1; d1=sin(2*pi*d*t)j

fl=sin(2*pi*f*t); gl=sin(2*pi*g*t); bH=sin (2*pi*bf*t); cf=s In (2*pi",c*t);

dl1=sin(2*pi*d2*tl); d12=sin(2*pi*d*tl)j

asc .. [d1 sl H 51 gl 51 bfls1 c1 52 dI1]; % Create ascending scale

dsc=[cl sl bil s1 gl sl f1 s1 d12]; % Create descending scale

y=[asc 51 dsc slJ; sound(y)% Malkauns scale (y)

% Sampling interval

% Time for each note (0.4 s) % Silent period (0.1 s)

% Shorter silent period (0.05 s)

% Time for last note of each scale

% Start generating the notes

(Solution)

%i'B.OBLEM 3.40 fO .. 340;

d",fO;

f .. fO*(2~(3/12»; . g=f()* (2~{5/12»; bf .. fO*(2~(8/12»; c=f()*(2~(10/12»; d2",,2*d;

ts=1/8192; %Sampling interval·· t=O;ts;O.4; %time for each note sl=O*(O:ts:O.l);%silent period s2=O*(0:ts:0.05); %shorter silent period

tl ... O: ts: 1; %timefor last notre of a5C and desc scale

d1"'sin(2*pHd*t) ;f1=sin(2*pi*f*t) ;gl=sin(2*pHg*t) ;bf1=sin(2*pi*bf*t);

... cl .. sin (2*pi*c*t) ;dl1=sin(2*pHd2*tl) ; d12"sin (2*pi*d*tl) ; .

a.sc=[d1s1 Hslg1 slbfl slcis2dl1];%Create a5C scale

dsc";[c1 sl bfl sl gl s1ft sl<d12J;%Crea.te desc scale

y=[asc sl dsc s1]; %Malkauns scale

soundf y)

2.41 (Music Synthesis II) The raw scale of raga malkauns will sound pretty dry! The reason for

this is the manner in which the sound from a musical instrument is generated. Musical instruments produce sounds by the vibrations ofastring (in string instruments) or a column of air (in woodwind instruments). Each instrument has its characteristic sound. In a guitar, for example, the strings are plucked, held, and then released to sound the notes. Once plucked, the sound dies out and decays. Furthermore, the notes are never pure but contain overtones (harmonics). For a realistic sound, we must include the overtonesand thel1ttack,sustl1in,andrelease (decay) characteristics. The sound signal may be considered to have the form x{t) "",a(t)cos(21rfot + B), where fo is the pitch and a(t) is the envelope that describes the attack-sustain-release characteristics of the instrument played. A crude representation of some envelopes is shownin Figure P2.41 (the piecewise linear approximations will work just aswell for ourpurposes). Wood~indinstruments have a much longer sustain time and a much shorter release time than do plucked string and keyboard instruments.

Chapter 2 Solutions to Problems

27

art)

Envelopes of woodwind instruments

art) Envelopes of

1 • "', string and keyboard .instrume ',

Figure P2.41Envelopes and their piecewise linearapproximations (dark) for pwplem.2.41 Experiment with the scale of raga malkauns and try to produce a guitar-like Bound, using the appropriate envelope form. You should be able to discern an audible improvement.

(Solution)

.. ··i',PROBLEM.3.41

..• %FROM .Prob .. ·3.40 .

'fO=340;d=fO;f;;;fO*(2A(3/12»;g=fO*(2~(5/12»;bf==fO*(2~(8/12»;

c=fO*(2~C10/12»;d2=2*d;t5"'1/8192;t=0:t5:0.4;sl=0*(0:t5:0.1); s2=O*(O:ts:0.05);tl"O:ts:1;d1=f;in(2*pi*d*t);f1"sin(2*pi*f*t); gl=sin(2*pi*g*t);bfl=sin(2*pi*bf*t); cl=sin(2*pi*c*t);dl1=5inC2*pi*d2*tl);d12=sin(2*pi*d*tl); asc=[dl 51 f1 51 g1 51 bfl 51c152d111;

ds c=j c I 51 bf1 51 gl 51 f1 s1dl2] jy=[asc sldscs11;soundCy)

%We now let each note decay by adding an exponential decay ex=exp(-5*t);ex1=exp(-4*tl)j

asc=[d1.*ex 51 fl.*ex s1g1.*ex 51 bf1.*ex 51 c1.*ex 52 dll.*ex1]; dsc=Ic Lvex 51 bf1.*ex 51 g1.*ex slf1.*ex 51 dl2.*ex1] j

yhd=[a5c 51 d5C 51];

sound (yhd)

2.42 (Music Synthesis III) Synthesize the following notes, using a woodwind envelope, and synthesize

the same notes using a plucked string envelope. .

Ffl(O.3) D(O.4) E(O.4) A(l) A(O.4) E(O.4) FU(O.3) D(l)

All the notes cover one octave, and the numbers in parentheses give a rough indication of their relative duration. Can you identify the music? (His Big Ben.)

(Solution)

'%PROBLEM 3.42 fO=260;a=fO;f5=fO*(2~(9/12»;d=fO*(2-(5/12»;e==fO*(2-(7/12»; ts=1/8192;t1==0:ts:O.7;t2>=O:ts:1:51"O*CO:ts:O.05);tl=0:t5:1: f1=5in(2*pi*fs*t1) jd1=sin(2*pi*d*t1) je1=sin(2*pHe*tl);d 2=sin(2*pi*d*t2); a1=5in(2*pi*a*ti); a2=5inC2*pi*a*t2) :

bb= [f1 51 d1 51 e I 51 a2 81 81 sf, a1 81 e1 81 f1 51 d2]; %Big Ben Notes 50und(bb)

28

Chapter 2 Discrete Signals

%Then add decay for. string-like sound ex1=exp(-4*t1);ex2=exp(-3*t2);

bb2=[f1.*exl, 51, d1.*ax1, 51, e1 .• ex1, 51, a2.*ex2];

bb2 .. [bb2, 51, 51,51, sl, s1,a1.*ex.1, 51, e1.*ex1, sl, fl.*ex1]; bb2=(bb2, sl, d2.*ex2]isouIld(bb2)

. .

2.43 (Music Synthesis IV) Synthesize the first bar of Pictures at an Exhibition by Mussorgsky,which

has the following notes: ..

A(3) G(3) C(3) D(2) G*(l) E(3) D(2) G*(l) E(3) C(3) D(3) A(3) G(3)

All the notes cover one octave except the note G*, which is an octave above G. The numbers in parentheses give a rough indication of the relative duration of the notes (for more details, you may want to listen to an actual recording). Assume that a keyboard instrument (such as a piano) is played.

[Solut.ion}

'l,PRDBLEM 3.43

fO=440; a",:fO;g=fO*C2-(-2/12»;c=fO*(2A(3/12»;d",fO*(2R{SI12»;

gg=fO* (2~ (10/12» j a=fO* (2~(7112»; ..

t5=1/8192;t1=0:ts:0.6jt2=0:ts:0.3;sl=0*(0:ts:O.06)jtl=O:ts:1; al=sin(2*pi*a*t1);g1=sin(2*pi*g*t1)jc1=sin(2*pi*c*tl); d1=sin(2*pi*d*t1)jd2=sin(2*pi*d*t2);

g2"sinC2*pi*gg*t2) ;

e1=sin(2*pi*e*t1);

p=[al sl gl s1 c1 51 d2 51 g2s1 al sl d2 51 g2 sl el s1]; p"[p cl 51 dl 51 al 51 gl s L] ; %First bar of Pictures 50und(p)

%Add decay for string-like sound ex1""exp( -4*tl); ex2""exp(-3*t2);

pd=[a1.*exl 51 g1.*8xl 51 c1.*exl sl d2.*ex251g2.*ex2 51 e1.*exl 51 d2.*ex2]; pd=jpd 51 g2.*ex2 51 a1.*exl 51 c1.*exl 51 d1.*exl 51 a1.*ex1 51 g1.*ax1 51];

50und(pd) .

2.44 (DTMF Tones) In dual-tone multi-frequency (DTMF) or touch-tone telephone dialing, each number is represented by a dual-frequency tone. The frequencies for each digit are listed in Chapter 18.

(a) Generate DTMF tones corresponding to the telephone number 487-2550, by sampling the sum of two sinusoids at the required frequencies at S = 8192Hz for each digit. Concatenate the signals by putting 50 zeros between each signal (to represent silence) and listen to the signal using the MATLAB command sound.

(b) Write a MATLAB program that generates DTMF signals corresponding to a vector input representing the digits in a phone number. Use a sampling frequency of S = 8192 Hz.

(Solution)

Chapter 2 Solutions to Problems

29

(a) %PROBLEM 3.44 %PART (a)

%1= [697 ,1209] %6 .. (770 ,1477]

2=[697,1336] 7=[852,1209}

3= [697 ,1477] 8=[852,1336]

4"'[770,1209} 9=[852,1477]

5'" [770,1336] 0= [941,1336]

S=8192; wh1~2*pi*1209/Sjwh2=2*pi*1336/Sjwh3~2*pi*1477/Si wll=2*pi*697/SiW12=2*pi*770/SiW13=2*pi*852/Sjw14=2*pi*941/S; %Generate 1000 samples each

z=zeros(1,1000)j %50 zeros is too short!!

N=1000;n=O:N-i;

four=[sin(u*w11)+sin(n*wh1),z];

eight= [siu(n*w13)+sin(n*wh2) ,zJ i seven=[sin(n*w13)+sin(n*wh1),z,z,z] ; two=[sin(n*wl1)+sin(n*wh2),Z]i five=[siu(n*w12)+sin(n*wh2),z]; oh=[sin(n*w14)+sin(n*wh2),z] j ph~[four,eight,seven,two,five,five,oh];sound(ph)

(b) Here is one of the many possible solutions.

function [sigtt,snd]=dialtt(n,S)

%dial(n,S) Sound of tones in a phone number at sampling freq S %S=sampling freq (Defaults to 8192 Hz)

!,n=vector or array of digits in the phone number %NOTE: Use 10 for * and 12 for # on the dial

% Use sound(sigtt) to listen to the tones

%See getnum.m (in Chapter 18) to decode the signal

if nargin<2,S=8192;end low=[697 770 852 941];

hi=[1209 1336 1477J;

n=nf : ) ; i=find(n==O);n(i)=11+0*i; M=1000;z=zeros(1.M);

N=O: M-i;

l=length(n) j

s·igtt .. [] ; snd ... [J ; for kool: 1 n(k);ih=rem(n(k)-i,3)+1;il=fix«n(k)-1)/3)+1; tone=[low(il) hi(ih)];

snd=[snd;tone] ;

sigtt=[sigtt, cos(2*pi*tone(i)*N/S)+cos(2*pi*tone(2)*N/S)];

if k<l, sigtt .. [sigtt, z]; end %add zeros to all except lastdigi t

!.make column %Change 0 to 11 %silent passage

end

You might also like