Discrete-time first-order systems 1 Start with the continuous-time system ẏ(t) =ay(t)+bu(t), y(0) Zero-order hold input u(t) =u(nt ), nt apple t<(n + 1)T u(t) is held constant for the sample period T Solution y(t) = e at y(0) + y(t ) = e at y(0) + Z t e a(t 0 Z T e a(t 0 y(t ) = Ay(0) + Bu(0) A = e at, B = Z T 0 e a(t ) bd = ) bu( ) d ) bd u(0) Z T e a 0 bd = T, d = d =0, = T = T, =0
Discrete-time first-order systems II 2 Sampled values of zero-order-held continuous-time Zsystem T y(t ) = Ay(0) + Bu(0) A = e at, B = e a bd y[1] = Ay[0] + Bu[0] 0 General update of samples y[n + 1] = Ay[n]+Bu[n] This is a first-order difference equation Solution y[1] = Ay[0] + Bu[0] y[2] = Ay[1] + Bu[1] = A 2 y[0] + ABu[0] + Bu[1] y[3] = Ay[2] + Bu[2] = A 3 y[0] + A 2 Bu[0] + ABu[1] + Bu[2]. =. y[n] = A n y[0] + nx 1 k=0 A n k 1 Bu[k] Easy!!
Discrete-time higher-order systems 3 Second-order system (Example 2.6, p. 60) y[n] 1.5y[n 1] + y[n 2] = 2u[n 2] Initial conditions y[ 2] = 2, y[ 1] = 1 input u[n] = 1[n] Solution y[n] = 1.5y[n 1] y[n 2] + 2u[n 2] y[0] = 1.5y[ 1] y[ 2] + 2u[ 2] = 1.5 1 1 2+2 0= 0.5 y[1] = 1.5y[0] y[ 1] + 2u[ 1] = 1.5 ( 0.5) 1 1+2 0= 1.75 y[2] = 1.5y[1] y[0] + 2u[0] = 1.5 ( 1.75) 1 ( 0.5) + 2 1=.125 y[3] = 1.5y[2] y[1] + 2u[1] = 1.5 ( 0.125) 1 ( 1.75) + 2 1=3.5625
Higher-order discrete-time systems 4 Nth-order linear system y[n]+a 1 y[n 1] + a 2 y[n 2] + + a N y[n N] =b 0 u[n]+b 1 u[n 1] + + b M u[n M] y[n] = a 1 y[n 1] a 2 y[n 2] a N y[n N] +b 0 u[n]+b 1 u[n 1] + + b M u[n M] Solution via the recursion/substitution Easy to program Clearly we need N initial conditions y[-1],, y[-n] The solution consists of two parts that due to initial conditions only zero-input response that due to the input only zero-state response
5 Discrete impulse response, convolution Discrete impulse signal Zero initial conditions Output is the impulse response General inputs Response to Response to u[n] = k= 1 u k [k n] y[n] =h[n] u k [k n] is u k h[k n] u[n] is u k h[k n] = 4 Discrete u[n] h[n] Convolution k= 1 [n] = ( 1, if n =0 0, else
6 Discrete step response Discrete step function 1[n] = Relationship with discrete impulse ( 1, if n 0 0, else 1[n] = Step response is the integral of the impulse response nx k= 1 [k] s[n] = 1[n] h[n] = k= 1 1[n k]h[k] = ( Pn k=0 h[k], n 0 0, else
Z-transforms 7 Start by considering the Laplace transform of a one-sided sampled-data signal Define L [x s (t)] = = Z 1 0 x s (t)e st dt = x n e snt Z 1 z = e st then Z (x[n]) = X(z) = 4 This is the z-transform of the sequence {x[n]} It is analogous to the Laplace transform in continuous time But it is much easier to work with 0 e st 1 X x n (t nt ) dt x[n]z n
Some z-transforms 8 Discrete impulse sequence Z ( [n]) = [n]z n =1 Delayed impulse Z ( [n k]) = [n k]z n = z k General delayed signal Z (x[n k]) = x[n k]z n = n=k Multiplication of the z-transform by z -1 is a delay operation by one sample time We can extend the z-transform to two-sided signals easily There is still a convergence question m=0 x[m]z m k = z k X(z)
9 Z-transform of a discrete step Z (1[n]) = This uses the geometric series formula It converges if z > 1 We can extend this to a geometric series Z(a n 1[n]) = a n z n 1 = 1 az 1 = z z This converges if 1z n =1+z 1 + z 2 + = k=0 z > a 1 1 z 1 = z z 1 x[n] =a n 1[n] a
Z-transform and convolution 10 Z(x[n] v[n]) = X(z)V (z) Z(x[n] v[n]) = = = = x[k]v[n k]z n k=0 k=0 x[k]z k v[n k]z x[k]z k k=0 x[k]z k X 1 m= k X 1 k=0 m=0 v[m]z m (n k) v[m]z m = X(z)V (z)
Z-transforms 11 Recall the relationship between Laplace and Z-transforms z = e st Laplace transforms of signal which decay have poles in Re(s) < 0 Z-transforms of sequences which decay have poles in z < 1 Recall the first-order sampled system ẏ(t) =ay(t)+bu(t), y(0) Its discrete variant was with A = e at, B = The continuous mode/pole is at s=a y[n + 1] = Ay[n]+Bu[n] Z T 0 e a bd The discrete mode/pole is at z=a=e at Note that for any T>0 e at < 1, Re(a) < 0
Z-transforms and delays 12 Original sequence x[n] ={x 0,x 1,x 2,x 3,...} Z-transform X(z) = x[n]z n = x n z n Delayed/shifted sequence X s (z) = = x s [n] ={0,x 0,x 1,x 2,...} x s [n]z n = x s nz n X 1 x n 1 z n = z 1 x n z n n=1 = z 1 X(z) Recall L [f(t T )1(t T )] = e st F (s) z = e st
Discrete system transfer functions 13 Example ODE Solve by recursion with initial conditions Let s take the z-transform y[n]z n = 0.1 y[n] + 0.1y[n 1] 0.72y[n 2] = 0.1u[n 1] + 0.9u[n 2] y[n] = 0.1y[n 1] + 0.72y[n 2] + 0.1u[n 1] + 0.9u[n 2] y[n 1]z n +0.72 Denote the solution z-t by y[n 2]z n +0.1 Y (z) and the input z-t by A discrete transfer function The initial conditions get mixed in at recursion u[n 1]z n +0.9 u[n U(z) 2]z n Y (z) = 0.1z 1 Y (z)+0.72z 2 Y (z)+0.1z 1 U(z)+0.9z 2 U(z) Y (z)+0.1z 1 Y (z) 0.72z 2 Y (z) = 0.1z 1 U(z)+0.9z 2 U(z) Y (z) = 0.1z 1 +0.9z 2 1+0.1z 1 0.72z 2 U(z)
Discrete impulse response 14 G(z) = 0.1z 1 +0.9z 2 1+0.1z 1 0.72z 2 = 0.1z +0.9 z 2 +0.1z 0.72 From the transfer function recreate the ODE y[n] = 0.1y[n 1] + 0.72y[n 2] + 0.1u[n 1] + 0.9u[n 2] Crank it: zero i.c., u[n]=δ[n] y 0 = "0.1# y "1 + 0.72 # y "2 + 0.1# u "1 + 0.9 # u "2 = "0.1# 0 + 0.72 # 0 + 0.1# 0 + 0.9 # 0 = 0 y 1 = "0.1# y 0 + 0.72 # y "1 + 0.1# u 0 + 0.9 # u "1 = "0.1# 0 + 0.72 # 0 + 0.1#1 + 0.9 # 0 = 0.1 n n y 2 = "0.1# y 1 + 0.72 # y 0 + 0.1# u 1 + 0.9 # u 0 = "0.1# 0.1 + 0.72 # 0 + 0.1# 0 + 0.9 #1 = 0.89 y 3 = "0.1# y 2 + 0.72 # y 1 + 0.1# u 2 + 0.9 # u 1 = "0.1# 0.89 + 0.72 # 0.1 + 0.1# 0 + 0.9 # 0 = "0.017 y 4 = "0.1# y 3 + 0.72 # y 2 + 0.1# u 3 + 0.9 # u 2 = "0.1# "0.017 + 0.72 # 0.89 + 0.1# 0 + 0.9 # 0 = 0.6425
Impulse response via matlab 15 dimpo=dimpulse([0 0.1 0.9],[1 0.1-0.72],50); stem(dimpo, filled )
Impulse response via partial fractions 16 Same as for Laplace and just as much fun Y (z) = G(z)U(z) = 0.1z 1 +0.9z 2 1+0.1z 1 0.72z 2 1 0.1z +0.9 = z 2 +0.1z 0.72 = 98/170 81/170 z 0.8 z +0.9 = 98 170 z 1 81 1 0.8z 1 170 z 1 1+0.9z 1 = 98 170 z 1 1 81 1 0.8z 1 170 z 1 Note that the stable poles yield exponentially decaying terms These modes are very fast near z=-1 Rapid changes in the response 1 1+0.9z 1 = 98 170 z 1 1+0.8z 1 +0.64z 2 +0.512z 3 +... 81 170 z 1 1 0.9z 1 +0.81z 2 0.729z 3 +... = 0+0.1z 1 +0.89z 2 0.017z 3 +0.6425z 4... = Z [{0, 0.1, 0.89, 0.017, 0.6425,...}]
Matlab does partial fractions 17 >> [r,p,k]=residue([0.1 0.9],[1 0.1-0.72]) r = -0.4765 0.5765 p = -0.9000 0.8000 k = [] >> [dimpulse(1,[1-0.8],10) dimpulse(1,[1 0.9],10) r(1)*dimpulse(1,[1 0.9],10)+r(2)*dimpulse(1,[1-0.8],10)] 0 0 0 1.0000 1.0000 0.1000 0.8000-0.9000 0.8900 0.6400 0.8100-0.0170 0.5120-0.7290 0.6425 0.4096 0.6561-0.0765 0.3277-0.5905 0.4702 0.2621 0.5314-0.1021 0.2097-0.4783 0.3488 0.1678 0.4305-0.1084
Discrete frequency response 18 >> sys=tf([0.1 0.9],[1 0.1-0.72],1) Transfer function: 0.1 z + 0.9 ------------------ z^2 + 0.1 z - 0.72 Magnitude (db) 15 10 5 0 Bode Diagram Sampling time (seconds): 1 >> bode(sys) 5 10 0 90 Phase (deg) 180 270 360 10 2 10 1 10 0 10 1 Frequency (rad/s)
Summary of discrete time 19 Continuous-time Signals: functions Systems: ODEs, impulse response, state space Laplace transforms: poles stability in Re[s]<0 Fourier transforms: Frequency content Frequency response Frequency axis Convolution Discrete-time Signals: sequences Systems: ODEs, impulse response, state space Z transforms: Poles stability in z <1 Discrete Fourier transforms: Frequency content Frequency response Frequency axis s = j! z = e j! Convolution via FFT
Digital filters 20 Applied to data as a sequence Matlab commands yield the transfer function elements butter, ellip, cheby1, cheby2, FIR >> help butter butter Butterworth digital and analog filter design. [B,A] = butter(n,wn) designs an Nth order lowpass digital Butterworth filter and returns the filter coefficients in length N+1 vectors B (numerator) and A (denominator). The coefficients are listed in descending powers of z. The cutoff frequency Wn must be 0.0 < Wn < 1.0, with 1.0 corresponding to half the sample rate. First 13 lines If Wn is a two-element vector, Wn = [W1 W2], butter returns an order 2N bandpass filter with passband W1 < W < W2. [B,A] = butter(n,wn,'high') designs a highpass filter. [B,A] = butter(n,wn,'low') designs a lowpass filter. [B,A] = butter(n,wn,'stop') is a bandstop filter if Wn = [W1 W2].