Signals and Systems Lab2. Linear Time-Invariant Systems
Signals and Systems Lab2. Linear Time-Invariant Systems
𝑥𝑛 = 𝑥 𝑘 𝛿[𝑛 − 𝑘]
𝑘=−∞
n = 1:4;
x = [1 2 0.5 1];
stem(n,x,'filled'); xlabel('n');
title('x[n]');
xticks([1 2 3 4 ]); yticks([0 0.5 1
1.5 2]);
box off; grid on;
+∞
𝑥𝑛 = 𝑥 𝑘 𝛿[𝑛 − 𝑘]
𝑘=−∞
Another example
Time index for
nonzero values
n = 11:14;
x = [1 2 0.5 1];
stem(n,x,'filled'); xlabel('n');
title('x[n]');
xticks([11 12 13 14]); yticks([0
0.5 1 1.5 2]);
box off; grid on;
S is linear
+∞ +∞
𝑥𝑛 = 𝑥 𝑘 𝛿[𝑛 − 𝑘] S 𝑦𝑛 = 𝑥[𝑘] ℎ𝑘 [𝑛]
𝑘=−∞ 𝑘=−∞
S is time-invariant
ℎ𝑘 𝑛 = ℎ[𝑛 − 𝑘]
+∞ +∞
𝑥𝑛 = 𝑥 𝑘 𝛿[𝑛 − 𝑘] S 𝑦𝑛 = 𝑥 𝑘 ℎ[𝑛 − 𝑘]
𝑘=−∞ 𝑘=−∞
Convolution Sum!
𝑦𝑛 = 𝑥 𝑘 ℎ[𝑛 − 𝑘]
𝑘=−∞
𝑦 𝑛 = 𝑥[𝑛] ∗ ℎ[𝑛]
h 𝑛 = 𝛿 𝑛 + 𝛿 𝑛 − 1 + 𝛿[𝑛 − 2]
𝑥 𝑛 = 0.5𝛿 𝑛 + 2𝛿[𝑛 − 1]
𝑦 𝑛 = 0.5ℎ 𝑛 + 2ℎ[𝑛 − 1]
This is convenient only for sequences
with short durations!
① x k as a whole;
② Flip ℎ[𝑘] to ℎ −𝑘 ;
③ Shift ℎ[−𝑘] to ℎ[𝑛 − 𝑘] for each n;
④ Multiply 𝑥[𝑘] with ℎ[𝑛 − 𝑘] over the whole k axis;
𝑘
𝑥 𝑘 ℎ 𝑛−𝑘 = 𝛼 0≤𝑘≤𝑛
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
⑤ Sum over k, obtain the value of 𝑦[𝑛] for the specific time index n;
⑥ For other values of n, return to step 3 to do shift-multiplication-
summation again.
This is the usual way to
calculate convolution!
𝑢[𝑘] ⋯ 𝑘 𝑣[𝑘]
𝑎
⋯ 𝑘
𝑎+1 𝑎+2 𝑎+𝑁 𝑏 𝑏+1 𝑏+𝑀
𝑦 𝑛 =𝑢 𝑛 ∗𝑣 𝑛 = 𝑢 𝑘 𝑣[𝑛 − 𝑘]
𝑘=−∞
Define 𝑢, 𝑛𝑢 and 𝑣, 𝑛𝑣;
Calculate 𝑦[𝑛] by 𝑦 = 𝑐𝑜𝑛𝑣(𝑢, 𝑣);
Calculate the time index for nonzero values of 𝑦[𝑛]
𝑛𝑦 = 𝑛𝑢 1 + 𝑛𝑣 1 : 𝑛𝑢 𝑒𝑛𝑑 + 𝑛𝑣(𝑒𝑛𝑑)
u = [1 1 0.5 1.5];
nu = 3:6;
v = [1 1];
nv = 5:6;
y = conv(u,v);
ny = nu(1)+nv(1):nu(end)+nv(end);
subplot(3,1,1);
stem(nu,u,'r');xlim([3,12]);xlabel('n');
title('u[n]');
subplot(3,1,2);
stem(nv,v,'g');xlim([3,12]);xlabel('n');
title('v[n]');
subplot(3,1,3);stem(ny,y,'b');xlim([3,12
]);xlabel('n');title('y[n]=u[n]*v[n]');
𝑎𝑘 𝑦 𝑛 − 𝑘 = 𝑏𝑘 𝑥[𝑛 − 𝑘]
𝑘=0 𝑘=0
Linear constant-
coefficient difference + The condition
= Causal LTI
of initial rest system
equation
𝑎𝑘 𝑦 𝑛 − 𝑘 = 𝑏𝑘 𝑥[𝑛 − 𝑘]
𝑘=0 𝑘=0
𝑀
𝑏𝑘 Non-recursive
𝑁=0 𝑦𝑛 =
𝑎0
𝑥[𝑛 − 𝑘] No need for auxiliary
𝑘=0
conditions
Impulse response has
FIR 𝑏𝑛 finite duration
0≤𝑛≤𝑀
ℎ 𝑛 = 𝑎0 The output can be
calculated by conv(x,h)
0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
Example: 𝑦 𝑛 = 𝑥 𝑛 + 0.5𝑥 𝑛 − 1 + 2𝑥[𝑛 − 2]
Recursive
Auxiliary conditions is
𝑁≥1 Impulse response has
required
infinite duration Impulse response has
IIR infinite duration
Example: 𝑦 𝑛 − 0.8𝑦[𝑛 − 1] = 2𝑥 𝑛 The output cannot be
calculated by conv(x,h)
𝑦 = 𝑓𝑖𝑙𝑡𝑒𝑟(𝐵, 𝐴, 𝑥)
A = [1 -0.8];
B = 2;
x1 = [1]; % input is unit impulse,
output is the unit impulse response
y1 = filter(B,A,x1); y1n = 0;
x2 = [1 0 0 0];
y2 = filter(B,A,x2); y2n = 0:3;
x3 = [1 0 0 0 0 0 0 0 0 0 0];
y3 = filter(B,A,x3); y3n = 0:10;
subplot(3,1,1); stem(y1n,y1); xlim([0,10]);
subplot(3,1,2); stem(y2n,y2); xlim([0,10]);
subplot(3,1,3); stem(y3n,y3); xlim([0,10]);
MATLAB assume 𝑦 −1 = 0
yn = 𝑏𝑚 𝑥[𝑛 − 𝑚]
𝑚=0
𝒘 = 𝒄𝒐𝒏𝒗(𝒖, 𝒗) 𝒚 = 𝒇𝒊𝒍𝒕𝒆𝒓(𝒃, 𝒂, 𝒙)
Signal of finite duration Signal of finite duration
FIR FIR and IIR
𝑛𝑤 𝑛𝑦 = 𝑛𝑥
= 𝑛𝑢 1 Truncated output
+ 𝑛𝑣 1 : 𝑛𝑢 𝑒𝑛𝑑
+ 𝑛𝑣(𝑒𝑛𝑑)
a = [1 0.5 -0.2];
b = 10;
k = 20;
impz(b,a,k)
Number
of points
MATLAB assume 𝑦 −2 = 𝑦[−1] = 0
For the above system, compute and plot in the time interval
0 ≤ 𝑛 ≤ 20
+∞
𝛿 𝑡 = lim 𝛿∆ (𝑡)
∆→0 𝑥(𝑘∆)𝛿∆ (𝑡 − 𝑘∆)∆
+∞
𝑥 𝑡 = lim 𝑥 𝑡 = 𝑥 𝜏 𝛿 𝑡 − 𝜏 𝑑𝜏
∆→0 −∞
S is linear
+∞ +∞
+∞ +∞
𝑥 𝑡 = 𝑥 𝜏 𝛿 𝑡 − 𝜏 𝑑𝜏 S 𝑦 𝑡 = 𝑥 𝜏 ℎ 𝑡 − 𝜏 𝑑𝜏
−∞ −∞
Convolution Integral!
1
1 1 1
0
t
0 0 0 1
① Flip ℎ(𝜏) to ℎ(−𝜏); 0
② Shift ℎ(−𝜏) to ℎ(𝑡 − 𝜏) for any t;
③ Multiply 𝑥(𝜏) with ℎ(𝑡 − 𝜏) over the whole 𝜏 axis; 1
−(𝑡−𝜏) 𝑡 > 0
𝑥(𝜏)ℎ(𝑡 − 𝜏) = 𝑒
0 𝑡≤0 t 0
⑤ Integrate over 𝜏, obtain 𝑦(𝑡)
1
0 t
Linear constant-
coefficient differential + The condition
= Causal LTI
of initial rest system
equation
𝑀
1 𝑑 𝑘 𝑥(𝑡) Differentiate the input
𝑁=0 𝑦(𝑡) =
𝑎0
𝑏𝑘
𝑑𝑡𝑘
explicitly
𝑘=0
No need for auxiliary
conditions
Implicit
Auxiliary conditions is
𝑁≥1 𝑦 𝑡 = 𝑦ℎ 𝑡 + 𝑦𝑝 (𝑡) required
The response consists
of two parts— a
Example: 𝑦(𝑡) − 0.8𝑦(𝑡) = 2𝑥(𝑡) particular solution plus
a homogeneous
solution
𝑦 = 𝑙𝑠𝑖𝑚 𝐵, 𝐴, 𝑥, 𝑡
𝑦 = 𝑙𝑠𝑖𝑚(𝑠𝑦𝑠, 𝑥, 𝑡) Transfer
function
𝑠𝑦𝑠 = 𝑡𝑓(𝐵, 𝐴)
Impulse response: 𝑦 = 𝑖𝑚𝑝𝑢𝑙𝑠𝑒 𝐵, 𝐴, 𝑡
Step response: 𝑦 = 𝑠𝑡𝑒𝑝(𝐵, 𝐴, 𝑡)
𝐴 = [𝑎𝑁 ⋯ 𝑎2 𝑎1 𝑎0 ] 𝐵 = [𝑏𝑀 ⋯ 𝑏1 𝑏0 ]
𝑁 𝑀
𝑑 𝑘 𝑦(𝑡) 𝑑 𝑘 𝑥(𝑡)
𝑎𝑘 = 𝑏𝑘
𝑑𝑡𝑘 𝑑𝑡𝑘
𝑘=0 𝑘=0
Transmitter Receiver
Attenuation 0.6; delay 2
Wireless Channel (LTI System)
𝑦 𝑛 = 0.8𝑥 𝑛 − 1 + 0.6𝑥 𝑛 − 2 + 0.4𝑥[𝑛 − 3]
Transmitter Receiver
Attenuation 0.6; delay 2
Wireless Channel (LTI System)
% Generate Tx signal
x = [1 2 3 4 0 0 0 1 2 5 0 0 ];
% Obtian Rx signal by simulating the wireless channel
a1 = 1;
b1 = [0 0.8 0.6 0.4];
y = filter(b1,a1,x);
% Compare the transmitted signal with the received
signal
figure(1);
subplot(2,1,1); stem(x); title('transmitted signal
x[n]');
subplot(2,1,2); stem(y); title('received signal
y[n]');
Impulse Response: or
Difference Equation:
Attenuation 𝛼; delay N
Attenuation 1; delay 0
Transmitter Receiver
𝑦 𝑛 = 𝑥 𝑛 + 𝛼𝑥 𝑛 − 𝑁
𝑦 𝑛 = 𝑥 𝑛 + 𝛼𝑥 𝑛 − 𝑁
min 𝑦 𝑛 − 𝑦[𝑛]
𝛼,𝑁
Cross-correlation: 𝜙𝑥𝑦 𝑛 = +∞
𝑚=−∞ 𝑥 𝑚 + 𝑛 𝑦 𝑚 = 𝑥[𝑛] ∗ 𝑦[−𝑛]
Cross-correlation: 𝜙𝑥𝑦 𝑛 = +∞
𝑚=−∞ 𝑥 𝑚 + 𝑛 𝑦 𝑚 = 𝑥[𝑛] ∗ 𝑦[−𝑛]
nx = 100; x = randn(1,nx);
N = 50; alpha = 0.9; 𝑦 𝑛 = 𝑥 𝑛 + 0.9𝑥 𝑛 − 50
y = filter([1 zeros(1,N-1) alpha],1,x);
Rxx = conv(x,fliplr(x));
Ryy = conv(y,fliplr(y));
Ryx = conv(y,fliplr(x));
figure;
subplot(3,1,1); plot([-nx+1:nx-1],Rxx);grid on;
title('autocorrelation of x[n]');
subplot(3,1,2); plot([-nx+1:nx-1],Ryy);grid on;
title('autocorrelation of y[n]');
subplot(3,1,3); plot([-nx+1:nx-1],Ryx);grid on;
title('cross-correlation of y[n] and x[n]');