Uploaded by Osteo

LabA03 03-LTISystem

advertisement
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 = filter(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
Download