Discrete Signal Processing Lecture 2 Signals and systems review Part 2 DSP background material The Unit Impulse (Unit Sample) Review of properties of the unit impulse Definition Shifting Sifting Connection to the unit step System Properties Inpulse response Convolution ECNG3025 © F.Muddeen 2 1 Unit impulse (unit sample) Defined as: δ [n] = 0, n ≠ 0 = 1, n = 0 Shifted (Delayed) 2 2 1.8 1.8 δ [n] 1.6 1.4 1.6 δ [n − 3] 1.4 1.2 1.2 1 1 0.8 0.8 0.6 0.6 0.4 0.4 0.2 0.2 0 -8 -6 -4 -2 0 2 4 6 ECNG3025 0 -4 8 -2 0 2 4 6 8 10 12 3 © F.Muddeen Unit impulse and Unit step Close relationship Unit impulse is first difference of unit step δ [n] = u[n] − u[n − 1] Remember that CT impulse was the first derivative of the CT step Alternatively: u[n] = ∞ ∑ δ [ m] m = −∞ Called a running sum. Analogous to integration Only non zero value is at m = 0, so that summation agrees with definition of the unit step. ECNG3025 © F.Muddeen 4 2 Sifting Property Multiplying any sequence signal by a unit impulse selects or ‘sifts’ out the value of the sample signal at the instant of the impulse: x[n] ⋅ δ [n] = x[0] x[n] ⋅ δ [n − k ] = x[k ] The well known sifting property of impulses We can ‘build’ any sequence using this property Called Sampling ECNG3025 5 © F.Muddeen DT sequence from Impulses Does this look familiar? A convolution type summation ECNG3025 © F.Muddeen 6 3 Summarising ECNG3025 © F.Muddeen 11 Summarising ECNG3025 © F.Muddeen 12 6 Systems A discrete-time system transforms an input sequence into an output sequence according to some input/output rule. Can be done sample by sample Thus: H [ x0 , x1 , x2 , L xn ] ⎯⎯→ [ y0 , y1 , y2 ,L yn ] Called sample by sample processing Real-time systems would use this technique ECNG3025 13 © F.Muddeen Systems OR ⎡ x0 ⎤ ⎡ y0 ⎤ ⎢y ⎥ = y H x = ⎢⎢ x1 ⎥⎥ ⎯⎯→ ⎢ 1⎥ ⎢⎣ xn ⎥⎦ ⎢⎣ yn ⎥⎦ Called block processing For systems where data is stored ⎡2 0 0⎤ ⎡ x0 ⎤ y = Hx = ⎢⎢0 3 0⎥⎥ ⎢⎢ x1 ⎥⎥ ⎢⎣0 0 4⎥⎦ ⎢⎣ x3 ⎥⎦ The technique used depends on the particular DSP application ECNG3025 © F.Muddeen 14 7 Required System Properties Linearity If input consists of a number of weighted signals Overall response is a linear superposition of responses to each individual signal. Thus: F [a1 x1 (n) + L + an xn (n)] = a1F [ x1 (n)] + L + an F [ xn (n)] ECNG3025 © F.Muddeen 15 Properties of DSP systems Time-invariance Relationship between input and output does not change with time If y[n ] = F [ x[n ]] then y[n − k ] = F [ x[n − k ]] and y[ n ] = y[ n − k ] Causality System is causal if the output of system only exists for n ≥ 0 Most commonly encountered type of systems ECNG3025 © F.Muddeen 16 8 Causal Signal Discrete-time signal Made up of a set of weighted unit samples (impulses) with appropriate delay. Thus Will discuss this in detail when dealing ∞ with sampling x ( n) = x(k )δ (n − k ) ∑ k =0 No signal before n=0 (causal) ECNG3025 17 © F.Muddeen Impulse Response Linear time invariant (LTI) systems are uniquely characterised by their impulse response Recall this from earlier on So that each ECNG3025 x[n] = ∞ ∑ x[k ]δ [n − k ] k = −∞ δ [n − k ] → h[n − k ] © F.Muddeen 18 9 Impulse Response Therefore y[ n] = ∞ ∑ x(k )h[(n − k ] k = −∞ •This is also expressed as: n = 0, 1, 2, K y[n] = x[n] ∗ h[n] The convolution sum ECNG3025 © F.Muddeen 19 Impulse Response If h[n] does not converge Infinite Impulse Response system IIR If h[n] converges Finite Impulse Response system FIR To be discussed ECNG3025 © F.Muddeen 20 10 The Convolution Equation Let us assume a causal sequence ∞ y[n] = ∑ x(k )h[(n − k ] n = 0, 1, 2, K k =0 ∞ y[0] = ∑ x(k )h[(0 − k )] k =0 What is h[-k]? ECNG3025 That is simply ©h[k] reversed (‘flipped’) F.Muddeen 21 Continuing y[0] = x(0)h(0) + x(1)h( −1) + x(2)h(−2) + K + ∞ y[1] = ∑ x(k )h[(1 − k )] k =0 h[-k] shifted right once! That is a slide y[1] = x(0)h(1 − 0) + x(1)h(1 − 1) + x(2)h(1 − 2) + K + y[1] = x(0)h(1) + x(1)h(0) + x(2)h(−1) + K + ECNG3025 © F.Muddeen 22 11 Eventually y[2] = x(0)h(2) + x(1)h(1) + x(2) h(0) + K + Let us apply this to an example and observe the pattern x[n]=[1 3 4] h[n]=[5 4 2] Find y[n]=x[n]*h[n] ECNG3025 23 © F.Muddeen Start n x[k] h(-(k)) -2 -1 2 4 0 1 5 1 3 Reversed sequence 2 4 3 4 5 6 7 Overlap begins here y[0] = x(0)h(0) + x(1)h( −1) + x(2)h(−2) + K + y[0] = (1)(5) = 5 ECNG3025 © F.Muddeen 24 12 Shift once (‘slide’) n x[k] h(-(k)) h(1-k) -2 -1 0 1 1 3 2 4 5 2 4 3 4 5 6 7 Overlap zone y[1] = x(0)h(1) + x(1)h(0) + x(2)h(−1) + K + y[1] = (1)(4) + (3)(5) = 19 ECNG3025 25 © F.Muddeen Slide again n x[k] h(-(k)) h(1-k) h(2-k) -2 -1 0 1 1 3 2 4 2 4 5 3 4 5 6 7 Overlap zone y[2] = x(0)h(2) + x(1)h(1) + x(2) h(0) + K + y[2] = (1)(2) + (3)(4) + (4)(5) = 34 ECNG3025 © F.Muddeen 26 13 Finish off n x[k] h(-(k)) h(1-k) h(2-k) h(3-k) h(4-k) h(5-k) -2 -1 2 4 2 0 1 5 4 2 1 3 5 4 2 2 4 5 4 2 3 5 4 2 4 5 4 5 7 y(n) y(0)=5 y(1)=19 y(2)=34 y(3)=22 y(4)=8 y(5)=0 5 x[n]=[1 3 4] h[n]=[5 4 2] Find y[n]=x[n]*h[n] Answer [5 19 34 ©22 8] F.Muddeen ECNG3025 6 Overlap ends here 27 Another approach ∞ y[n] = ∑ x(k )h[(n − k )] k =0 y[0] = x(0)h(0) + x(1)h( −1) + x(2)h(−2) + K + y[1] = x(0)h(1) + x(1)h(0) + x(2)h(−1) + K + y[2] = x(0)h(2) + x(1)h(1) + x(2) h(0) + K + . . . ECNG3025 If we are dealing with causal systems then h(-1), h(-2) etc are zero © F.Muddeen 28 14 Another approach ∞ y[n] = ∑ x(k )h[(n − k )] k =0 y[0] = x(0)h(0) y[1] = x(0)h(1) + x(1) h(0) y[2] = x(0)h(2) + x(1)h(1) + x(2) h(0) . . . Let’s enter this into a table ECNG3025 29 © F.Muddeen Using 4 terms for x[n] and 3 for h[n] x[0] h[0] h[0]x[0] h[1] h[1]x[0] x[1] x[2] x[3] x[4] h[0]x[4] h[2] h[3] h[3]x[0] h[3]x[4] Called a Convolution Table ECNG3025 © F.Muddeen 30 15 Enter the values from our example Sum across the anti-diagonals 1 3 4 5 5 15 20 4 4 12 16 2 2 6 8 y[0] = x(0)h(0) = 5 y[1] = x(0)h(1) + x(1)h(0) = 19 y[2] = x(0)h( 2) + x(1)h(1) + x(2)h(0) = 34 y[3] = 22 y[4] = 6 ECNG3025 31 © F.Muddeen Sequence Xn Sequence Hn 4 5 4 3 3 2 2 1 0 1 1 1.5 2 2.5 3 0 1 1.5 2 2.5 3 Sequence Yn 35 30 Graphical representation of results 25 20 15 10 5 0 ECNG3025 1 2 3 4 5 © F.Muddeen 32 16 Example Find the output of a finite response system h[nT ] = nT to the input signal x[nT ] = e − nT , where T = 0.1s and n = 0 to 3 Step 1 Find the sequences h[nT]=? x[nT]=? ECNG3025 © F.Muddeen 33 Using MATLAB conv function % % % Use of the conv function ECNG3025 2006 (c) F.Muddeen n=0:3; Xn=exp(-0.1*n); Hn=0.1*n; Yn=conv(Xn,Hn); Subplot(2,2,1),stem(Xn,'fill');Title('Sequence Xn'); Subplot(2,2,2),stem(Hn,'fill');Title('Sequence Hn'); Subplot(2,2,3),stem(Yn,'fill');Title('Sequence Yn'); ECNG3025 © F.Muddeen 36 17 Using MATLAB conv function Sequence Xn Sequence Hn 1 0.4 0.8 0.3 0.6 0.2 0.4 0.1 0.2 0 1 2 3 4 0 1 2 3 4 Sequence Yn 0.8 0.6 The results agree with those obtained before 0.4 0.2 0 0 ECNG3025 2 4 6 8 © F.Muddeen 37 18