9/26/22 ELG 3125 Signal and System Analysis Lab Lab A03_03: LTI System and Convolution Sum Wenbo Wu University of Ottawa September 26, 2022 1 Outline • LTI System in Continuous-Time • LTI System in Discrete-Time • Convolution • Audio Signal ©W. Wu 2 2 1 9/26/22 LTI System in Continuous-Time ©W. Wu 3 3 Continuous-Time LTI System • N-th order linear constant-coefficient differential equation: • Describe the system in MATLB • To find the impulse response h(t) of the system: impulse(B,A,t) • To compute the output given the input x(t): lsim(B,A,x,t) ©W. Wu 4 4 2 9/26/22 Example 1 • Second order continuous-time causal LTI system: !' "($) !"($) + 2 !$ + 3π¦ !$ ' ! ! "($) 1 !$ ! +π π‘ = !"($) !$ !&($) + 6π₯ !$ + ππ¦ π‘ = π π‘ , ! ! &($) !$ ! +π π¨ = π π π , π© = [π π π] !&($) !$ + ππ₯ π‘ • Coefficients are highest-order first from left to right in the vector • The size of A and B should be the same A=[1 2 3]; B=[0 1 6]; t=0:0.01:30; impulse(B,A,t); ©W. Wu 5 5 Example 2 • For the continuous-time causal LTI system: ! ! "($) !$ ! +5 !"($) !$ + 6π¦ π‘ = π₯ π‘ • (a) Find and plot the impulse response h(t) of the system, using the function impulse(b,a,t) where b and a correspond to the coefficients in the differential equation.(i.e. a=[1,5,6] and b=[0,0,1]). t=0:0.001:20; a=[1 5 6]; b=[0 0 1]; impulse(b,a,t); grid; ©W. Wu 6 6 3 9/26/22 Example 2 … • (b) For an input signal defined as: π₯ π‘ = 1 − π '($ π’(π‘), compute the output y(t) of that system, using the function lsim(b,a,x,t). Using a time range long enough to see the y(t) signal stabilize. t=0:0.001:20; a=[1,5,6]; b=[0,0,1]; x=1-exp(-3*t); y=lsim(b,a,x,t); plot(t,y); grid; ©W. Wu 7 7 LTI System in Discrete-Time ©W. Wu 8 8 4 9/26/22 Discrete-Time LTI System • N-th order linear constant-coefficient difference equation: • Describe the system in MATLB • To find the impulse response h[n] of the system: impz(B,A,n) • To compute the output given the input x(n): filter(B,A,x) ©W. Wu 9 9 Example 3 • Second order causal LTI system • Coefficients are most present time first from left to right in the vector A=[1 -0.4 0.75] B=[2.2403 2.4908 2.2403] • The size of A and B should be the same ©W. Wu 10 10 5 9/26/22 Example 3 … • The MATLAB command impz(B,A,n) can be used to compute the first N samples of the impulse response of the causal LTI discrete-time system. N = 40; B = [2.2403 2.4908 2.2403]; A = [1 -0.4 0.75]; h = impz(B,A,N); stem(h); xlabel('n samples'); ylabel('Amplitude'); Ntle('Impulse Response'); grid; ©W. Wu 11 11 Example 4 • Consider a discrete-time system characterized by the difference equations. Use input x[n] to compute the output of the system. • System: • Coefficient vector A? B? 20ππ • Input: π₯ π = cos 256 + cos 200ππ , π€ππ‘β 0 ≤ π ≤ 299. 256 ©W. Wu 12 12 6 9/26/22 Example 4 … n = 0:299; x = cos(2*pi*10*n/256)+cos(2*pi*100*n/256); % Compute the output sequences A=[1 -0.53 0.46]; B=[0.45 0.5 0.45]; y = ο¬lter(B,A,x);% Output of System stem(y); ylabel('Amplitude'); Stle('Output of System'); grid; • Check the length of output length(y) ©W. Wu 13 ©W. Wu 14 13 Convolution 14 7 9/26/22 Convolution Sum • Mathematical formula: • MATLAB function: y=conv(x,h) ©W. Wu 15 15 Example 5 • A discrete-time system given by Example 4, compute output of system by using conv(). • System: • Input: π₯ π = cos 20ππ 200ππ + cos , π€ππ‘β 0 ≤ π ≤ 299. 256 256 ©W. Wu 16 16 8 9/26/22 Example 5 … n = 0:299; x = cos(2*pi*10*n/256)+cos(2*pi*100*n/256); % Compute the output sequences A=[1 -0.53 0.46]; B=[0.45 0.5 0.45]; h=impz(B,A,n); y = conv(x,h);% Output of System stem(n,y(1:length(n))); ylabel('Amplitude'); Stle('Output of System'); grid; • Check the length of y • Length of y equals to length(x)+length(h)-1 ©W. Wu 17 ©W. Wu 18 17 Audio Signal 18 9 9/26/22 Operate Music Files • audioread(): read a music file • sound(): play the music ©W. Wu 19 19 Example 6 • Obtain a discrete time input signal x[n] by reading a music file“Audio1.wav”. This signal has duration (length) of 190912 samples, with a sampling frequency of 16000 samples/sec. • Visualize the resulting signals and listen to it. x= audioread('Audio1.wav'); sound(x); stem(x); ©W. Wu 20 20 10 9/26/22 End of Lab A03_03 ©W. Wu 21 21 11