You are on page 1of 15

University of Manchester (School of Computer Science)

CS3291 : Digital Signal rocessing !"#$"% Section 3 : Discrete$time &'( systems


3)1 (ntro*uction: A discrete time system as shown in Figure 3.1 takes a discrete time input signal, i.e. a sequence of samples { x[ n !, and produces a discrete time output signal { y[ n !. input {x[n]} SYSTEM +ig) 3)1 "uch a system could #e implemented using a general purpose computer, a microcomputer or a dedicated piece of digital hardware which is capa#le of carrying out arithmetic operations on the samples of { x[ n ! and { y[ n !. $emem#er, from "ection 1, that { x[ n ! is a sequence whose %alue at time t&n' is x[ n . "imilarly for { y[ n !. ' is the sampling inter%al in seconds and therefore 1(' is the sampling frequency in )*. +y this notation, { x[ n,- ! is a sequence whose %alue at t&n' is x[ n,- . 'herefore { x[ n,- ! is the original sequence { x[ n ! with e%ery sample delayed #y - sampling inter%als. .any different types of discrete time system can #e considered, for example/ 0i1A discrete time 2 amplifier 2 whose output y[n at time t&n' is some constant, A, times the input x[n . 'his system is descri#ed #y the 2 difference equation 2/ y[n & A x[n . 3t is represented in diagram form #y the 2 signal flow graph 2 in Figure 3.4. A x[n] +ig) 3)2 0ii1A processing system whose output at time t&n' is calculated #y weighting and summing present and pre%ious input samples as descri#ed #y the 2 non,recursi%e difference equation 2/ y[n & A 1 x[n 5 A 4 x[n,1 5 A 3 x[n,4 5 A 6 x[n,3 5 A 7 x[n,6 A signal flow graph for this difference equation is shown in Figure 3.3. 'he #oxes marked 2 * ,1 2 produce a delay of one sampling inter%al so that if the input to a 2 * ,1 2 #ox is x[ n , the output will #e x[ n,1 , and if the input to a 2 * ,1 2 #ox is x[n,1 the output is x[ n,4 . 'he reason for the 2 * ,1 2 notation will #e explained later. y[n] output {y[n]}

8"3491 :"; +.>8

3.4

1<(=1(4=16

x[n]

z-1

z-1 A3

z-1 A4

z-1 A5

A1

A2

y[n]

+ig) 3)3 0iii1A system whose output y[n at t & n' is calculated according to the following 2 recursi%e 2 difference equation/ y[n & A = x[n , + 1 y[n,1 whose signal flow graph is gi%en in Figure 3.6. 'he term 2recursi%e2 means that pre%ious %alues of y[n as well as present and pre%ious %alues of x[n are used to calculate the output y[n . x[n] y[n] z-1 -B1 +ig) 3), 0i%1A system whose output at t&n' is/ y[n & 0x[n 1 4 as represented in Figure 3.7. x[n] +ig) 3)# y[n]

A0

3)2) &inear time$invariant (&'() Systems: 'o #e classified as ?'3, a discrete,time system must ha%e the following two properties/ (() &inearity ( Superposition ): >i%en any two discrete time signals {x 1 [n ! and {x 4 [n !, if the system@s response to {x 1 [n ! is denoted #y {y 1 [n ! and its response to {x 4 [n ! is denoted #y {y 4 [n ! then for any %alues of the constants k 1 and k 4 , its response to k 1{x 1[n ! 5 k 4{x 4[n ! must #e k 1{y1[n ! 5 k 4 {y 4 [n ! . 'o multiply a sequence #y a constant, we simply multiply each element #y the constant, e.g. k{x[n ! & {kx[n !. Also, to add two sequences together, we add corresponding samples, e.g. {x[n ! 5 {y[n ! & {x[n 5 y[n !.1 ((() 'ime$invariance ( sometimes calle* - shift - invariance ):

8"3491 :"; +.>8

3.3

1<(=1(4=16

>i%en any discrete time signal {x[n !, if the system@s response to {x[n ! is {y[n !, its response to {x[n,- ! must #e {y[n,- ! for any %alue of -. 'his means that delaying the input signal #y - samples must produce a corresponding delay of samples in the output signal. 3t may #e shown that Axamples 0i1, 0ii1 and 0iii1 in "ection 3.1 are ?'3 0 su#Bect to reasona#le assumptions a#out starting points 1 whereas 0i%1 is not ?'3.

3)3) (mpulse response: 3t is useful to consider the response of ?'3 systems to a special discrete time signal referred to a 2 discrete time unit impulse 2, or in short an 2 impulse 2. 'his signal is denoted #y { d [n ! and is illustrated in Figure 3.C. Aach sample of the sequence is defined #y/ 1 / n = = d[n = = / n =

d[n] 1 ... -3 -2 -1 0 1 +ig) 3)% 2 3 4 5 ... n ...

d[n-4] 1 n -3 -2 -1 0 1 2 3 +ig) 3). 4 5 ...

'he sequence { d[ n,- ! is clearly a delayed impulse where the only non,*ero sample occurs at n&rather than at n&= as illustrated with -&6 in Figure 3.<. 'he system@s output when the input is { d[n ! is referred to as the impulse response of the system. 3t may #e shown that if the impulse response of an ?'3 system is known, its response to any other input signal may #e deduced. De shall normally refer to the impulse response as { h[n !. 3),) Computing an impulse$response: 8onsider a discrete time system which implements the signal,flow graph in Figure 3.3 with A1, A4, A3, A6 and A7 set to specific constants. 'he required system could #e realised #y a microcomputer running a program with the flow diagram #elow. A high,le%el language implementation would #e of the form listed alongside.

8"3491 :"; +.>8

3.6

1<(=1(4=16

Set 0140245) 2ero 314 324 334 3,43# (6 U' 3

7 8 0193 : 02932 : 03933 :))) ;U' U' 7 3# 8 3,< 3, 8 33< 33 8 32< 32 831

clear allF A1&1F A4&4F A3&3F A6&,6F A7&7F x1&=F x4&=F x3&=F x6&=F x7&=F while Gisempty0E1 E & input0 @E & @1F x1 & EF H& A1Ix1 5 A4Ix4 5 A3Ix3 5 A6Ix6 5 A7Ix7 F disp0[@ H & @ num4str0H1 1F x7 & x6 F x6 & x3F x3 & x4 F x4 &x1F endF J .A'?A+ program

/ere is another version using M0'&01 arrays/ A = [1 2 3 -4 5 ] ; x = [0 0 0 0 0 ] ; while 1 X = input( 'X = '); x(1)=X; Y=A(1) * X; fo ! = 2 " 5 Y = Y # A(!)*x(!); en$; $i%p([' Y = ' nu&2%t (Y)]); fo !=5"-1"2 x(!) = x(!-1); en$; en$; 0n* an even more efficient version A = [1 2 3 -4 5 ] ; x = [0 0 0 0 0 ] ; while 1 x(1) = input( 'X = '); Y = A(1)*x(1); fo ! = 5 " -1" 2 Y = Y # A(!)*x(!); x(!) = x(!-1); en$; $i%p([' Y = ' nu&2%t (Y)]); en$; 'he impulse,response for this example may #e deduced #y running any of the programs referred to a#o%e and entering the following sequence of %alues for E on the key#oard / =, =, =, 1, =, =, =, =,.... 'he sequence of output samples printed out will #e / =, =, =, A1, A4, A3, A6, A7, =, =, .... Dhere a computer is not a%aila#le, the same result can #e o#tained #y ta#ulation 0 see #elow 1. -ote that the output must #e *ero until the input #ecomes equal to 1 0 at n&= 1, and that only fi%e non,*ero output samples are o#ser%ed. Axpressed as an infinite sequence, the impulse response is/ {...,=,...,=, A1, A4, A3, A6, A7, =, =, ... ,=,...! where the sample at n&= is underlined. 'his is said to #e a 2 finite impulse response 2 as only a finite num#er of samples are non,*ero.

8"3491 :"; +.>8

3.7

1<(=1(4=16

Axercise 3.1/ 8alculate the impulse responses for the following two difference equations/ 0i1 y[n & x[n 5 4 x[n,1 5 3 x[n,4 , 6 x[n,3 5 7 x[n,6 0ii1 y[n & 6 x[n , =.7 y[n,1 "olutions/ 3f a computer is not a%aila#le we may use a ta#ulation method. Dhereas difference equation 0i1 produces a finite impulse response as expected, difference,equation 0ii1 produces an 2 infinite response 2 whose samples gradually reduce in amplitude #ut ne%er quite #ecome *ero. 8onsider difference, equation 0i1/ n = 1 4 3 6 7 / x[n 1 = = = = = / x[n,1 = 1 = = = = / x[n,4 = = 1 = = = / x[n,3 = = = 1 = = / x[n,6 = = = = 1 = / y[n 1 4 3 ,6 7 = /

"olution is/, {.. =, .., =, 1, 4, 3, ,6, 7, =, .., =, ...!

-ow consider difference equation 0ii1/ y[n & 6 x[n , =.7 y[n,1 n = 1 4 3 6 7 / =>n? 1 = = = = = / y>n$1? = 6 ,4 1 =.7 =.47 / y>n? 6 ,4 1 ,=.7 =.47 ,=.147 /

"olution is/ {.., =, .., =, 6, ,4, 1, ,=.7, =.47, ,=.147, ...1 3)#) Digital filters: 'he term 2 digital filter 2 may #e applied to any digitally implemented ?'3 discrete time system whose #eha%iour is go%erned #y a difference equation of finite order. For example / y[n & x[n 5 4 x[n,1 5 3 x[n,4 , 6 x[n,3 5 7 x[n,6 y[n & 6 x[n , =.7 y[n,1 'he first of these difference equations is 2 non,recursi%e 2 and produces a finite impulse response 0F3$1. 'he second difference equation is 2 recursi%e 2 as pre%ious %alues of the output y[n are fed #ack into the right hand side of the difference equation. As we ha%e seen, the impulse,response of a

8"3491 :"; +.>8

3.C

1<(=1(4=16

recursi%e difference equation can ha%e an infinite num#er of non,*ero terms in which case it is said to #e an infinite impulse response 033$1. .A'?A+ function KfilterL used for non,recursi%e difference equation y & filter0A,1,x1 filters signal in array x to create array y. For each sample x0n1 of array x/ y0n1 & A011Ix0n1 5 A041Ix0n,11 5 ... 5 A0-511Ix0n,-1 Axample 0i1/ [x' f%' n(it%] = w)* e)$ ('+)p4th,w)*'); %oun$(x'f%'n(it%); p)u%e; - = filte ( [1 2 3 -4 5]' 1' x); %oun$(-'f%'n(it%); Mse of KfilterL for recursi%e difference equation y & filter0A,+,x1 filters signal in array x to create array y using a recursi%e difference equation. Axample 0ii1/ [x' f%' n(it%] = w)* e)$ ('+)p4th,w)*'); %oun$(x'f%'n(it%); p)u%e; - = filte ( [1]' [1 0,5]' x); %oun$(-'f%'n(it%);

3)%) Discrete time convolution: 3f the impulse,response of an ?'3 discrete time system is { h[n ! it may #e shown that the response to any input signal { x[n ! is an output signal { y[n ! whose samples are gi%en #y the following 2 con%olution 2 formula/ y[n =

m =

h[m

x[n m

An entirely equi%alent con%olution formula is/ y[n =

k =

x[k

h[n k

As an example, calculate the response of a system with impulse response/ {h[n ! & { ..., =,..., =, 1, 4, 3, ,6, 7, =, .....=, .... ! to the input signal/ {x[n ! & { ... =, ... , = , 1, 4, 3, =, ..., =, ....! +y con%olution, y[n =

m ==

h[n x[n m

= x[n + 4x[n 1 + 3x[n 4 6x[n 3 + 7x[n 6

"ince h[= &1, h[1 &4, h[4 &3, h[3 & ,6, h[6 &7 and all other samples of { h[n ! are *ero. 'his formula is not too surprising. 3t is the difference equation for an ?'3 system whose impulse response is {.., =, .., =, 1, 4, 3, ,6, 7, =, .., =, ..!. 'he computer program discussed earlier implements this difference equation, and we could complete the example #y running it, entering samples of { x[n !,

8"3491 :"; +.>8

3.<

1<(=1(4=16

and noting the output sequence. Alternati%ely, we could complete the example #y ta#ulation as follows/ n / ,1 = 1 4 3 6 7 C < / =>n? / = 1 4 3 = = = = = / =>n$1? / = = 1 4 3 = = = = / =>n$2? / = = = 1 4 3 = = = / =>n$3? / = = = = 1 4 3 = = / =>n$,? / = = = = = 1 4 3 = / y>n? / = 1 6 1= N C ,4 17 = /

{y[n ! & { .... =, ....., =, 1, 6, 1=, N, C, ,4, 17, =, ...., =, ....!

3).) roof of *iscrete time convolution formulae: De use only the definitions of linearity, time,in%ariance and the concept of an impulse response. "ince d[n,m is non,*ero only at n & m, it follows that gi%en any sequence {x[n !, x[n =

m =

x[m d[n m x[m {d[n m !

and therefore/ {x[n ! =


m =

'he sequence {x[n ! has thus #een expressed as the sum of an infinite num#er of delayed impulses, {d[n,m !, each multiplied #y a single element, x[m , of the sequence. 'here is a nice graphical representation of this 0see "ection 3.1<1. 3f {h[n ! is the system@s impulse response, the response to {d[n,m ! is {h[n,m ! for any %alue of a constant m. 'herefore, the response to {x[n ! as gi%en #y the formula a#o%e is the sequence/ {y[n ! =

m =

x[m {h[n m !
h[n m

and each element of this sequence is/ y[n =


m =

x[m

which is the first discrete time con%olution formula required. $eplacing n,m #y k gi%es the alternati%e formula. "tudy the graphical explanation of this proof in "ection 3.1<.

3)@) StaAility:

8"3491 :"; +.>8

3.N

1<(=1(4=16

An ?'3 system is 2 sta#le 2 if its impulse response {h[n ! satisfies /,

n =

h[n

is finite

'his means that {h[n ! must #e either a finite impulse response or an impulse response whose samples decay towards *ero as n tends to infinity. 3)9) Causality: Any practical ?'3 system operating in real time must #e 2 causal 2 which means that its impulse response {h[n ! must satisfy h[n & = for n O =. A non,causal system would need a P crystal #all Q to predict the future. 3)1") Belative +reCuency: :igital filters are often studied in terms of their effect on sinusoids of different frequencies. A discrete time sinusoid may #e o#tained #y sampling a continuous time sinusoid, A cos0 t 5 1 say, which has amplitude A, frequency radians(sec and phase lead radians. 3f the sampling period is ' seconds, the resulting discrete time signal is /
{A cos0Tn + 1! = {A cos0n + 1!

where replaces ' and is referred to as the 2 relati%e 2 frequency of the sampled sinusoid. 'he units of are @radians per sample@. 'o con%ert #ack to true frequency 0 in radians(sec 1 simply multiply #y 1('. -ote that 1(' is equal to the sampling frequency, f ", in samples(sec 0)*1 $emem#er/ K radians ( sample L times K samples ( second L & K radians ( second L. "ince discrete time systems are normally restricted to processing analogue signals in the range = to f " (4 0& 1(04'1 1, it is normally sufficient to restrict attention to %alues of in the range = to . 'he ta#le #elow gi%es a num#er of different %alues of and the corresponding true frequency in )ert* /,

B0D(06SDS0M &E = (C (6 (3 (4 4(3

'BUE +BEFUE6C7 (/EB'2) = fs(14 fs(N fs(C fs(6 fs(3 fs(4

8"3491 :"; +.>8

3.9

1<(=1(4=16

3)11) Belative freCuency response: 'he response of a discrete time ?'3 system to a sinusoidal input sequence may #e con%eniently calculated #y defining a theoretical signal with complex elements/
{e j n ! = {cos0 n1 + j sin0 n1!

3f this sequence could #e applied to a system with impulse response {h[n !, the output would #e, #y the con%olution formula, a sequence {y[n ! with /
y[n =

m =

h[ m e j0 n m1 =

m =

h[m e

jn

e jm

= e jn

m =

h[m e
j

jn

= H 0e j 1 e jn

where H 0 e

1= =

m =

h[m e

jm

n =

h[n e

jn

0:'F'1

)0 e B 1 is the 2 relati%e frequency response 2 of the system and is simply a complex num#er for any %alue of . 3t is the 2 discrete time Fourier transform 2 0 :'F' 1 of the sequence { h[n !. -ote the similarity to the analogue Fourier transform. De ha%e shown that if { e B n ! is the input to a system with impulse response {h[n !, the output will #e the same sequence with each element multiplied #y )0 e B 1. 3t can easily #e shown that when all samples of { h[n ! are real, )0 e ,B 1 is equal to the complex conBugate of )0 e B 1. Axercise/ ;ro%e this. 3)12) Gain an* phase responses: Axpressing )0 e B 1 in polar form as/
H 0 e j 1 = G 0 1 e j 0 1

>01 is the 2 gain 2 of the discrete time system and 01 is the 2 phase 2. +oth these quantities %ary with . 3t may #e shown that if the input to the system is a sinusoidal sequence {A cos0n1!, the output will #e/ { >01A cos0n 5 011 ! Axercise/ ;ro%e this either #y writing cos0 n 1 & 0 eBn 5e,Bn 1 ( 4 or cos0n1 & $eal part of { e Bn ! and using the result that when the input is eBn , the output is )0 eB 1 eBn . 'herefore when the input is a sampled sinusoid of relati%e frequency , the output is a sinusoid of the same relati%e frequency , #ut with amplitude scaled #y >01 and phase increased #y 01. 'his means that 01 is a phase lead. -ow write/ { >01A cos0n 5 011 ! & { >01A cos0 0n , k01 1 ! where k01 & ,01(.

8"3491 :"; +.>8

3.1=

1<(=1(4=16

3ncreasing the phase of a sinusoid #y 01 effecti%ely delays it #y k01 sampling inter%als where k01& ,01(. 3t is common practice to plot graphs of >0 1 and 01 against and refer to these graphs as gain and phase responses. >01 is often con%erted to deci#els 0 d+.1 #y calculating 4= log 1=0 >01 1. 3t is normally satisfactory to restrict to lie in the range = to and to adopt a linear hori*ontal scale. Axample 3.4/ 8alculate the gain and phase response of an F3$ digital filter with signal flow graph as in Figure 3.3 where A1 & 1, A4 & 4, A3 & 3, A6 & ,6, A7 & 7 . "olution/ As we ha%e seen, the impulse response is/ {.., =, .., =, 1, 4, 3, ,6, 7 ,=, .., =,..!. +y the formula esta#lished a#o%e, )0 e B 1 & 1 5 4 e , B 5 3 e ,4 B , 6 e ,3 B 5 7 e , 6 B and to o#tain the gain and phase at any gi%en %alue of we must e%aluate this expression, then take the modulus and phase of the resulting complex num#er. 'his is #est done #y computer, either #y writing and running a simple program, or #y running a standard package. A simple program is gi%en at the end of these notes. 'he gain and phase response for this particular F3$ filter may #e found #y running the program on a ;8. Alternati%ely a P spread,sheet Q package such as P .icrosoft Axcel Q may #e used to calculate and graphically represent the gain and phase response of )0 e B 1 . Driting )0 e B 1 as/ )0e B 1 & $01 5 B 301 where $01 & 154 cos01 5 3 cos041 , 6 cos031 5 7 cos0611 and 301 & , 4 sin041 , 3 sin041 5 6 sin031 , 7 sin061 it follows that the gain in deci+els at radians(sample is/ 4=Ilog1=0>011 & 1=Ilog1= 0 $01I$01 5 301I301 1 and the phase lag, in degrees, at radians(sample is , 01 & ,7<.49CIatan40$01, 301 1 'hese calculations can #e carried out using the spread,sheet for a range of starting at & = and ending at & 3.164 0approximately 1. 'he resulting columns for >01 and 01 can then #e graphed. 61 / 'he P Axcel Q atan40 x,y 1 function calculates the argument of the complex num#er x 5 B y in the range = to 4 radians. 3t is #etter than writing atan0 y(x 1 which gi%es an angle in the range , (4 to 5(4 and fails when x & =. 3n other languages, atan40 x,y 1 would ha%e to #e atan40 y,x 1. Another way of calculating the frequency response of )0 e B 1 is to use a mathematical computer language called P .A'?A+ Q. "imply log into .A'?A+ and type/ A & [ 1 4 3 ,6 7 F freq*0 A 1F

8"3491 :"; +.>8

3.11

1<(=1(4=16

'his produces graphs of the gain and phase responses corresponding to )0 e B 1 with a frequency scale normalised to half the sampling frequencyF i.e. the scale is la#elled = to 1 instead of = to . 0 'here are some %ariations in different %ersions of .A'?A+ 1 3n the next section 0 "ection 6 1 we will see how to calculate the coefficients 0 A=, A1, A4, etc. 1 of an F3$ filter to achie%e a particular type of gain and phase response. 'o calculate the gain and phase responses for the digital 33$ filter whose signal,flow graph is gi%en in Figure 3.6 would #e difficult 0though not impossi#le1 #y the method used a#o%e #ecause the impulse response has an infinite num#er of non,*ero terms. De shall disco%er a much easier method in a later section. 3)13) &inear phase response: 3f ,01( remains constant for all %alues of , i.e. if ,01 & k for some constant k, the system is said to ha%e a linear phase response. A phase response graph of , 01 against on a linear scale would then #e a straight line with slope k where k is the 2 phase delay 2 i.e. the delay measured in sampling inter%als 0 this need not #e an integer 1. ?inear phase systems are of special interest since all sinusoidal inputs will #e delayed #y the same num#er of sampling inter%als. An input signal expressed as a Fourier series, for example, will ha%e all its sinusoidal components delayed #y the same amount of time, and therefore, in the a#sence of amplitude changes, the output signal will #e an exact replica of the input. 3t is important to realise that ?'3 systems are not necessarily linear phase. )owe%er it will #e seen that a certain class of digital filter can #e made linear phase. 3)1,) (nverse D'+': 'he frequency response )0 e B 1 was defined in "u#section 3.11 as the :'F' of {h[n !. De now quote an in%erse formula which allows {h[n ! to #e deduced from a gi%en frequency response/
h[ n = 1 4

H 0e

1e jn d

/, O n O

6otes on inverse D'+': 1. R#ser%e the similarities #etween this formula and the in%erse analogue Fourier transform/, 0i1 the 01(41 factor, 0ii1 the sign of Bn 0n replaces t1 which is P5Q for the in%erse :'F' and was P,Q for the :'F'. 0iii1 the %aria#le of integration 0d1 4. 'he range of integration is now , to rather than , to . 0 corresponds to half the sampling frequency1. 3. -egati%e frequencies are again included. 6. Dith the :'F', the forward transform is a summation and the in%erse transform is an integral. 'his is #ecause {h[n ! is a sequence whereas )0e B 1 is a function of the continuous %aria#le .

8"3491 :"; +.>8

3.14

1<(=1(4=16

3)1# roAlems: 3.1. "how that y[n &0x[n 1 4 is not ?'3. 3.4. A digital ?'3 system has impulse response { .. =, .. , =, 1, ,1, =, .. =, .. !. 8alculate its response to {x[n ! & { .... =, .., =, 1, 4, 3, 6, =, .., =, ... !. 3.3. ;roduce a signal flow graph for each of the following difference equations/ 0i1 y[n & x[n 5 x[n,1 0ii1 y[n & x[n , y[n,1 3.6. For each difference equation in question 3.3, determine the impulse response, and deduce whether the discrete time system it represents is sta#le and(or causal. 3.7. 8alculate, #y ta#ulation, the output from difference equation 0ii1 in question 3.3 when the input is the impulse response of difference equation 0i1. 3.C. 3f the sampling frequency is N=== )*, what true frequency corresponds to a relati%e frequency of (7 radians per sampling inter%alS 3.<. 8alculate and sketch the gain and phase response of the system referred to in question 3.4. 0Hou don@t need a computer program for this one.1 3s it a linear phase systemS 3.N. 8alculate the impulse,response for y[n & 6x[n , 4y[n,1 . 3s it sta#leS 3.9. "how that input {cos0 n1! produces an output {>01cos0n5011!. 3.1=. For y[n &x[n 54x[n,1 53x[n,4 54x[n,3 5x[n,6 , sketch the phase,response and comment on its significance. "how that 01 & ,4.

8"3491 :"; +.>8

3.13

1<(=1(4=16

3)1%) rogam for calculating the gain H phase response of an +(B *igital filter)
;rogram F3$A-A?F {8alculates frequency response 0gain T phase1 of an F3$ digital filter.! uses >raphF %ar )/array[=..1== of realF >A3-,;)A"/ array[=..1N= of realF Fs,F,D,)re,)im,.:,;) / realF .,-,U, >rdri%er,>rmode,3E,3H/ integerF +egin writeln0@F3$ Frequency $esponse@1F write0@Anter sampling frequency0)*1/@1F read0Fs1F write0@Anter order of F3$ filter/@1F read0.1F writeln0@Anter coefficients/,@1F For - /& = to . do #egin write0@)[@,-,@ & @1F read0)[- 1F endF writeln0@ F$AV0)*1 >A3-0d+.1 ;)A"A ?AA:0deg1@1F U/& =F F/&=.=F {F is frequency in )*! Dhile F O Fs(4 do +egin )re/&=.=F )im/&=.=F D/&4I;3IF(FsF for -/&= to . do #egin )re/&)re5)[- Icos0DI-1F )im/&)im,)[- Isin0DI-1F endF .:/&sqrt0)reI)re5)imI)im1F if )re&= then #egin if )imO= then ;)/&,;3(4 else ;)/&,3I;3(4F endF if )reW= then ;)/& arctan0)im()re1F if )reO= then ;)/& arctan0)im()re1 , ;3F if ;)W= then ;)/&;),4.=I;3F 3f .:W= then >A3-[U /&4=Iln0.:1(ln01=1 else >A3-[U /&,999F ;)A"[U /&;)I1N=.=(;3F Driteln0F/1=/4, >A3-[U /1=/4,;)A"[U /1=/11F F/&F5F"(4==F U/&U51F AndF Sample run:$ F3$ F$AVMA-8H $A";R-"A Anter sampling frequency0)*1/ 1000 Anter order of F3$ filter/ 3 Anter coefficients/, )[= & 1 )[1 & 2 )[4 & 1 )[3 & 2 ;utput oAtaine*:$ Freq0)*1 >ain0:+1 = 17.7C 7 17.7C 1= 17.7C / / / 7== C.=1 ;hase0deg1 =.= ,3.= ,C.= ,1N=.= !

8"3491 :"; +.>8

3.16

1<(=1(4=16

3)1. Discrete time convolution graphically

x[n 3 4

{h[n ! & { ..., =, ..., =, 1, 4, 1, 4, =, ..., =, ,,,! {x[n ! & { ..., =, ..., =, 1, 4, 3, =, =, ..., =, ...!

n d[n h[n

4 n n 4d[n,1 6 4 4 n n 4h[n,1

3h[n,4 3d[n,4 3 C 3

E=press: {x[n ! & {d[n ! 5 4 {d[n,1 ! 5 3 {d[n,4 ! Besponse is: {y[n ! & {h[n ! 5 4 {h[n,1! 5 3 {h[n,4 ! 1= N C 6 4

y[n

3)1@) +reCuency response of +(B *igital filter Ay M0'&01 >i%en a discrete time ?'3 system whose non,recursi%e difference equation is/

8"3491 :"; +.>8

3.17

1<(=1(4=16

y[n & x[n 5 4 x[n,1 5 3 x[n,4 , 6 x[n,3 5 7 x[n,6 its impulse response is/ { ... , =, ... , =, 1 , 4, 3, ,6, 7, =, ..., =, ... ! and therefore its frequency response is/ )0 e B 1 & 1 5 4 e , B 5 3 e ,4 B , 6 e ,3 B 5 7 e , 6 B 'o calculate its gain and phase response using .A'?A+, at the .A'?A+ prompt, type/ freq* 0 [ 1 4 3 ,6 7 1 F 'he resulting graphs, shown #elow, ha%e a normalised frequency scale with P1Q corresponding to & radians(sampleF i.e. one half of the sampling frequency.

+ig) 3)9 'o calculate the gain and phase response of an ?'3 system with the recursi%e difference equation/ y[n & a 1 x[n 5 a 4 x[n,1 5 a 3 x[n,4 , #4 y[n,1 , # 3 y[n,4 At the .A'?A+ command type/ freq* 0 [a 1 a 4 a 3 , [ 1 #4 #3 1