Digital Signal Processing Discrete-Time Signals and Systems (1) Moslem Amiri, V´aclav Pˇrenosil Embedded Systems Laboratory Faculty of Informatics, Masaryk University Brno, Czech Republic amiri@mail.muni.cz prenosil@fi.muni.cz March, 2012 Discrete-Time Signals A discrete-time signal x(n) (≡ xa(nT)) is a function of an independent variable that is an integer We assume that x(n) is defined for every n for −∞ < n < ∞ x(n) is not defined for non-integer values of n 2 / 49 Some Elementary Discrete-Time Signals Unit sample sequence or unit impulse δ(n) ≡ 1, for n = 0 0, for n = 0 Figure 1: Graphical representation of the unit sample signal. 3 / 49 Some Elementary Discrete-Time Signals Unit step signal u(n) ≡ 1, for n ≥ 0 0, for n < 0 Figure 2: Graphical representation of the unit step signal. 4 / 49 Some Elementary Discrete-Time Signals Unit ramp signal ur (n) ≡ n, for n ≥ 0 0, for n < 0 Figure 3: Graphical representation of the unit ramp signal. 5 / 49 Some Elementary Discrete-Time Signals Exponential signal x(n) = an for all n If a is real, x(n) is a real signal Figure 4: Graphical representation of exponential signals. 6 / 49 Some Elementary Discrete-Time Signals Exponential signal x(n) = an for all n If a is complex a ≡ rejθ x(n) = rn ejθn = rn (cos θn + j sin θn) x(n) can be represented by separately plotting real part and imaginary part as functions of n xR (n) ≡ rn cos θn xl (n) ≡ rn sin θn Alternatively, x(n) can be represented by separately plotting amplitude and phase functions |x(n)| = A(n) ≡ rn ∠x(n) = φ(n) ≡ θn By convention, φ(n) is plotted over −π < θ ≤ π or 0 ≤ θ < 2π 7 / 49 Some Elementary Discrete-Time Signals Figure 5: Graph of the real (xR (n) ≡ rn cos θn) and imaginary (xl (n) ≡ rn sin θn) components of a complex-valued exponential signal for r = 0.9 and θ = π/10. 8 / 49 Some Elementary Discrete-Time Signals Figure 6: Graph of amplitude and phase function of a complex-valued exponential signal: (a) graph of A(n) = rn , r = 0.9; (b) graph of φ(n) = (π/10)n, modulo 2π plotted in the range (−π, π]. 9 / 49 Classification of Discrete-Time Signals Energy signals and power signals Energy E of a signal x(n) E ≡ ∞ n=−∞ |x(n)|2 If E is finite, x(n) is called an energy signal Many signals with infinite energy have a finite average power Average power of x(n) P = lim N→∞ 1 2N + 1 N n=−N |x(n)|2 If P is finite (and nonzero), x(n) is called a power signal 10 / 49 Classification of Discrete-Time Signals Example Power and energy of unit step sequence P = lim N→∞ 1 2N + 1 N n=0 u2 (n) = lim N→∞ N + 1 2N + 1 = lim N→∞ 1 + 1/N 2 + 1/N = 1 2 It is a power signal (its energy is infinite) Example Power and energy of complex exponential sequence x(n) = Aejω0n P = lim N→∞ 1 2N + 1 N n=−N A2 = lim N→∞ (2N + 1)A2 2N + 1 = A2 It is a power signal 11 / 49 Classification of Discrete-Time Signals Periodic signals and aperiodic signals x(n) is periodic with period N (N > 0) if and only if x(n + N) = x(n) for all n Smallest value of N is called fundamental period If there is no value of N that satisfies above equation, signal is called aperiodic Remember x(n) = A sin 2πf0n is periodic if f0 = k N = rational number Energy of a periodic signal over a single period is finite if it takes on finite values It is infinite for −∞ ≤ n ≤ ∞ Average power of a periodic signal is finite Equal to average power over a single period If x(n) is periodic with fundamental period N and takes on finite values P = 1 N N−1 n=0 |x(n)|2 Periodic signals are power signals 12 / 49 Classification of Discrete-Time Signals Symmetric (even) and antisymmetric (odd) signals Real-valued signal x(n) is symmetric (even) if x(−n) = x(n) x(n) is antisymmetric (odd) if x(−n) = −x(n) x(0) = 0 Any arbitrary signal can be expressed as sum of one even and one odd signal components xe(n) = 1 2 [x(n) + x(−n)] xo(n) = 1 2 [x(n) − x(−n)] x(n) = xe(n) + xo(n) 13 / 49 Classification of Discrete-Time Signals Figure 7: Example of even (a) and odd (b) signals. 14 / 49 Simple Manipulations of Discrete-Time Signals Transformation of independent variable (time) x(n) is shifted in time by replacing n by n − k If k > 0 −→ delay of signal by k units of time If k < 0 −→ advance of signal by |k| units in time x(n) is folded or reflected about time origin n = 0 by replacing n by −n Operations of folding (FD) and time delaying (TD) (or advancing) a signal are not commutative TDk [x(n)] = x(n − k), k > 0 FD[x(n)] = x(−n) TDk {FD[x(n)]} = TDk [x(−n)] = x(−n + k) FD{TDk [x(n)]} = FD[x(n − k)] = x(−n − k) x(n) is time scaled or down-sampled by replacing n by µn where µ is an integer If y(n) = x(2n) we know x(n) = xa(nT) y(n) = x(2n) = xa(2Tn) Hence this time-scaling operation is equivalent to changing sampling rate from 1/T to 1/2T −→ a down-sampling operation 15 / 49 Simple Manipulations of Discrete-Time Signals Figure 8: Graphical representation of a signal, and its delayed and advanced versions. 16 / 49 Simple Manipulations of Discrete-Time Signals Figure 9: Graphical illustration of the folding and shifting operations. 17 / 49 Simple Manipulations of Discrete-Time Signals Figure 10: Graphical illustration of down-sampling operation. 18 / 49 Simple Manipulations of Discrete-Time Signals Amplitude modifications Amplitude scaling by a constant A y(n) = Ax(n), −∞ < n < ∞ Sum of two signals y(n) = x1(n) + x2(n), −∞ < n < ∞ Product of two signals y(n) = x1(n)x2(n), −∞ < n < ∞ 19 / 49 Discrete-Time Systems Discrete-time system A device or algorithm that operates on a discrete-time signal called input or excitation, according to some well-defined rule, to produce another discrete-time signal called output or response of system Input signal x(n) is transformed by system into output signal y(n) y(n) ≡ τ[x(n)] Figure 11: Block diagram representation of a discrete-time system. 20 / 49 Input-Output Description of Systems Input-output description of a system Consists of a mathematical expression or a rule defining relation between input and output signals The only way to interact with system is by using its input and output terminals System is assumed to be a black box Exact internal structure of system is either unknown or ignored 21 / 49 Input-Output Description of Systems Example Response of following systems to the input signal x(n) = |n|, −3 ≤ n ≤ 3 0, otherwise x(n) = {. . . , 0, 3, 2, 1, 0 ↑ , 1, 2, 3, 0, . . .} 1 y(n) = x(n) (identity system) y(n) = x(n) = {. . . , 0, 3, 2, 1, 0 ↑ , 1, 2, 3, 0, . . .} 2 y(n) = x(n − 1) (unit delay system) y(n) = {. . . , 0, 3, 2, 1 ↑ , 0, 1, 2, 3, 0, . . .} 3 y(n) = x(n + 1) (unit advance system) y(n) = {. . . , 0, 3, 2, 1, 0, 1 ↑ , 2, 3, 0, . . .} 22 / 49 Input-Output Description of Systems Example (continued) 4 y(n) = 1 3[x(n + 1) + x(n) + x(n − 1)] (moving average filter) y(n) = {. . . , 0, 1, 5 3, 2, 1, 2 3 ↑ , 1, 2, 5 3, 1, 0, . . .} E.g., y(0) = 1 3[x(−1) + x(0) + x(1)] = 1 3[1 + 0 + 1] = 2 3 5 y(n) = median{x(n + 1), x(n), x(n − 1)} (median filter) y(n) = {. . . , 0, 2, 2, 1, 1 ↑ , 1, 2, 2, 0, . . .} 6 y(n) = n k=−∞ x(k) = x(n) + x(n − 1) + x(n − 2) + · · · (accumulator) y(n) = {. . . , 0, 3, 5, 6, 6 ↑ , 7, 9, 12, . . .} 23 / 49 Input-Output Description of Systems For some systems, output at n = n0 depends not only on input at n = n0, but on input values before and after n = n0 E.g., for accumulator y(n) = n k=−∞ x(k) = n−1 k=−∞ x(k) + x(n) = y(n − 1) + x(n) Given input signal x(n) for n ≥ n0, output y(n) for n ≥ n0 y(n0) = y(n0 − 1) + x(n0) y(n0 + 1) = y(n0) + x(n0 + 1) and so on The additional information required to determine y(n) for n ≥ n0 is initial condition y(n0 − 1) With no excitation prior to n0, initial condition is y(n0 − 1) = 0 System is initially relaxed Every system is relaxed at n = −∞ 24 / 49 Input-Output Description of Systems Example Following accumulator is excited by sequence x(n) = nu(n) y(n) = n k=−∞ x(k) Output of system y(n) = −1 k=−∞ x(k)+ n k=0 x(k) = y(−1)+ n k=0 x(k) = y(−1)+ n(n + 1) 2 If system is initially relaxed −→ y(−1) = 0 y(n) = n(n+1) 2 , n ≥ 0 If initial condition is y(−1) = 1 y(n) = 1 + n(n+1) 2 = n2+n+2 2 , n ≥ 0 25 / 49 Block Diagram Representation of Discrete-Time Systems Symbols used to denote different basic building blocks An adder This operation is memoryless (not necessary to store sequences) A constant multiplier (memoryless operation) A signal multiplier (memoryless operation) 26 / 49 Block Diagram Representation of Discrete-Time Systems Symbols used to denote different basic building blocks A unit delay element (requires memory) A unit advance element (requires memory) Example Using basic building blocks, sketch block diagram of y(n) = 1 4y(n − 1) + 1 2x(n) + 1 2x(n − 1) Shown in Fig. 12 (a) A simple rearrangement y(n) = 1 4y(n − 1) + 1 2[x(n) + x(n − 1)] Shown in Fig. 12 (b) 27 / 49 Block Diagram Representation of Discrete-Time Systems Example (continued) Figure 12: Block diagram realizations of the system y(n) = 0.25y(n − 1) + 0.5x(n) + 0.5x(n − 1). 28 / 49 Classification of Discrete-Time Systems: Static vs Dynamic Static or memoryless system Output at any instant n depends at most on input sample at same time, but not on past or future samples of input Dynamic A system which is not static Has memory If output at time n is completely determined by input samples from n − N to n (N ≥ 0), system is said to have memory of duration N N = 0 −→ system is static 0 < N < ∞ −→ system has finite memory N = ∞ −→ system has infinite memory 29 / 49 Classification of Discrete-Time Systems: Static vs Dynamic Example Following systems are static y(n) = ax(n) y(n) = nx(n) + bx3(n) Following systems are dynamic y(n) = x(n) + 3x(n − 1) This system has finite memory y(n) = n k=0 x(n − k) This system has finite memory y(n) = ∞ k=0 x(n − k) This system has infinite memory 30 / 49 Classification of D-T Systems:Time-Invariant,Time-Variant A relaxed system τ is time invariant or shift invariant if and only if x(n) τ → y(n) implies that x(n − k) τ → y(n − k) for every input signal x(n) and every time shift k To determine if any given system is time invariant 1 Excite system with an arbitrary sequence x(n), which produces y(n) 2 Delay input sequence by some amount k and recompute output y(n, k) = τ[x(n − k)] 3 If y(n, k) = y(n − k), for all possible k, system is time invariant. If not, even for one k, system is time variant 31 / 49 Classification of D-T Systems:Time-Invariant,Time-Variant Example Is this system time invariant or time variant?  1 z )1()()(  nxnxny)(nx  Input-output equation of system y(n) = τ[x(n)] = x(n) − x(n − 1) Delaying input by k units, it is clear from block diagram that y(n, k) = x(n − k) − x(n − k − 1) On the other hand, delaying y(n) by k units y(n − k) = x(n − k) − x(n − k − 1) Since y(n, k) = y(n − k), system is time invariant 32 / 49 Classification of D-T Systems:Time-Invariant,Time-Variant Example Is this system time invariant or time variant? )(nx  )()( nnxny  n Input-output equation of system y(n) = τ[x(n)] = nx(n) Response of this system to x(n − k) is y(n, k) = nx(n − k) If we delay y(n) by k units y(n − k) = (n − k)x(n − k) = nx(n − k) − kx(n − k) Since y(n, k) = y(n − k), system is time variant 33 / 49 Classification of D-T Systems:Time-Invariant,Time-Variant Example Is this system time invariant or time variant? )(nx )()( nxny   Input-output equation of system y(n) = τ[x(n)] = x(−n) Response of this system to x(n − k) is y(n, k) = τ[x(n − k)] = x(−n − k) If we delay y(n) by k units y(n − k) = x(−n + k) Since y(n, k) = y(n − k), system is time variant 34 / 49 Classification of D-T Systems:Time-Invariant,Time-Variant Example Is this system time invariant or time variant? )(nx  nnxny 0cos)()(  n0cos Input-output equation of system y(n) = x(n) cos ω0n Response of this system to x(n − k) is y(n, k) = x(n − k) cos ω0n If we delay y(n) by k units y(n − k) = x(n − k) cos ω0(n − k) Since y(n, k) = y(n − k), system is time variant 35 / 49 Classification of D-Time Systems: Linear vs Nonlinear A system is linear if and only if τ[a1x1(n) + a2x2(n)] = a1τ[x1(n)] + a2τ[x2(n)] for any arbitrary input sequences x1(n) and x2(n), and any arbitrary constants a1 and a2 A linear system satisfies superposition principle This principle requires that response of system to a weighted sum of signals be equal to the corresponding weighted sum of responses of system to each of individual input signals 36 / 49 Classification of D-Time Systems: Linear vs Nonlinear Figure 13: Graphical representation of the superposition principle. τ is linear if and only if y(n) = y (n). 37 / 49 Classification of D-Time Systems: Linear vs Nonlinear Linearity condition (superposition principle) τ[a1x1(n) + a2x2(n)] = a1τ[x1(n)] + a2τ[x2(n)] Suppose a2 = 0 τ[a1x1(n)] = a1τ[x1(n)] = a1y1(n) This is multiplicative or scaling property of a linear system If a1 = 0, then y(n) = 0 −→ a relaxed, linear system with zero input produces a zero output Suppose a1 = a2 = 1 τ[x1(n) + x2(n)] = τ[x1(n)] + τ[x2(n)] = y1(n) + y2(n) This is additivity property of a linear system Extension of linearity condition x(n) = M−1 k=1 ak xk (n) τ −→ y(n) = M−1 k=1 ak yk (n) where yk (n) = τ[xk (n)], k = 1, 2, . . . , M − 1 If a relaxed system does not satisfy superposition principle, it is nonlinear 38 / 49 Classification of D-Time Systems: Linear vs Nonlinear Example Determine if y(n) = nx(n) is linear or nonlinear For two inputs x1(n) and x2(n), outputs are y1(n) = nx1(n) y2(n) = nx2(n) A linear combination of two input sequences results in output y3(n) = τ[a1x1(n) + a2x2(n)] = n[a1x1(n) + a2x2(n)] = a1nx1(n) + a2nx2(n) A linear combination of two output sequences results in output a1y1(n) + a2y2(n) = a1nx1(n) + a2nx2(n) Since right-hand sides of two above equations are identical, system is linear 39 / 49 Classification of D-Time Systems: Linear vs Nonlinear Example Determine if y(n) = x(n2) is linear or nonlinear Response of system to two separate inputs x1(n) and x2(n) y1(n) = x1(n2) y2(n) = x2(n2) Output of system to a linear combination of x1(n) and x2(n) y3(n) = τ[a1x1(n) + a2x2(n)] = a1x1(n2) + a2x2(n2) A linear combination of two output sequences a1y1(n) + a2y2(n) = a1x1(n2) + a2x2(n2) Since right-hand sides of two above equations are identical, system is linear 40 / 49 Classification of D-Time Systems: Linear vs Nonlinear Example Determine if y(n) = x2(n) is linear or nonlinear Response of system to two separate inputs y1(n) = x2 1 (n) y2(n) = x2 2 (n) Response of system to a linear combination of these two inputs y3(n) = τ[a1x1(n) + a2x2(n)] = [a1x1(n) + a2x2(n)]2 = a2 1x2 1 (n) + 2a1a2x1(n)x2(n) + a2 2x2 2 (n) If system is linear, it will produce a linear combination of two outputs a1y1(n) + a2y2(n) = a1x2 1 (n) + a2x2 2 (n) Since right-hand sides of two above equations are not identical, system is nonlinear 41 / 49 Classification of D-Time Systems: Linear vs Nonlinear Example Determine if y(n) = Ax(n) + B is linear or nonlinear For two inputs x1(n) and x2(n), outputs are y1(n) = Ax1(n) + B y2(n) = Ax2(n) + B A linear combination of x1(n) and x2(n) results in output y3(n) = τ[a1x1(n) + a2x2(n)] = A[a1x1(n) + a2x2(n)] + B = a1Ax1(n) + a2Ax2(n) + B If system were linear, its output would be a1y1(n) + a2y2(n) = a1Ax1(n) + a1B + a2Ax2(n) + a2B The two results are different and system fails to satisfy linearity test. Reason is not that system is nonlinear but with B = 0 system is not relaxed. 42 / 49 Classification of D-Time Systems: Linear vs Nonlinear Example Determine if y(n) = ex(n) is linear or nonlinear This system is relaxed If x(n) = 0 −→ y(n) = 1 Hence system is nonlinear 43 / 49 Classification of D-Time Systems: Causal vs Noncausal A system is causal if its output at any time depends only on present and past inputs but not on future inputs y(n) = F[x(n), x(n − 1), x(n − 2), . . .] If a system does not satisfy this definition, it is noncausal Example These systems are causal y(n) = x(n) − x(n − 1) y(n) = n k=−∞ x(k) y(n) = ax(n) These systems are noncausal y(n) = x(n) + 3x(n + 4) y(n) = x(n2) y(n) = x(2n) y(n) = x(−n) e.g., n=−1 −−−−−−−→ y(−1) = x(1) 44 / 49 Classification of D-Time Systems: Stable vs Unstable A relaxed system is bounded input-bounded output (BIBO) stable if and only if every bounded input produces a bounded output x(n) and y(n) are bounded if there exist some finite numbers, Mx and My , such that for all n |x(n)| ≤ Mx < ∞, |y(n)| ≤ My < ∞ If for bounded x(n), output is unbounded (infinite), system is unstable Example Consider nonlinear system y(n) = y2(n − 1) + x(n) We select bounded input x(n) = Cδ(n) where C is a constant. Assume y(−1) = 0. Output sequence is y(0) = C, y(1) = C2, y(2) = C4, . . . , y(n) = C2n Output is unbounded when 1 < |C| < ∞ System is BIBO unstable 45 / 49 Interconnection of Discrete-Time Systems Systems can be interconnected in two ways to form larger systems Cascade (series) Parallel )(nx )(ny 1 )(1 ny 2 c )(nx 1 )(1 ny p  2 )(2 ny )(3 ny Figure 14: Cascade and parallel interconnections of systems. 46 / 49 Interconnection of Discrete-Time Systems In cascade interconnection Output of first system is y1(n) = τ1[x(n)] Output of second system y(n) = τ2[y1(n)] = τ2[τ1[x(n)]] Combining systems τ1 and τ2 into a single system τc τc ≡ τ2τ1 −→ y(n) = τc [x(n)] For arbitrary systems τ1 and τ2 τ2τ1 = τ1τ2 If systems τ1 and τ2 are linear and time invariant, then 1 τc is time invariant x(n − k) τ1 −→ y1(n − k) and y1(n − k) τ2 −→ y(n − k) thus x(n − k) τc =τ2τ1 −−−−−→ y(n − k) 2 τ2τ1 = τ1τ2 47 / 49 Interconnection of Discrete-Time Systems Output of parallel interconnection is y3(n) = y1(n)+y2(n) = τ1[x(n)]+τ2[x(n)] = (τ1 +τ2)[x(n)] = τp[x(n)] where τp = τ1 + τ2 Parallel and cascade interconnections can be used to construct larger, more complex systems Conversely, a larger system can be broken down into smaller subsystems for purposes of analysis and implementation 48 / 49 References John G. Proakis, Dimitris G. Manolakis, Digital Signal Processing: Principles, Algorithms, and Applications, Prentice Hall, 2006. 49 / 49