Professional Documents
Culture Documents
Lab - 05 Introduction To Properties of Systems: Faculty Member: Sikandar Hayat Dated: 01-April-2017
Lab - 05 Introduction To Properties of Systems: Faculty Member: Sikandar Hayat Dated: 01-April-2017
Lab Instructions
This lab activity comprises of three parts: Pre-lab, Lab Exercises, and Post-Lab Viva
session.
Only those tasks that completed during the allocated lab time will be credited to the
students. Students are however encouraged to practice on their own in spare time for
enhancing their skills.
if then
1.1.5 Linear / Non-linear Systems
Linear systems adhere to the principle of superposition. Superposition, comprises of
additivity and homogeneity.
y [n]+y [n]
1 2
OUTPUT
Scaling the input does not scale the output by the same degree, hence the
system is not linear.
b. Verify if the following system y[n] = x[n] + x[n+1] is not causal. Use the signal
x[n]=u[n] to deomstrate this. Define vectors x and y to represent the input on the
interval -5 n 9 and output on the interval -5 n 8.
CODE
n = [-5:9]; %Input x-axis scale.
u1 = [ 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1]; %The standard unit response.
u2 = [0 0 0 0 1 1 1 1 1 1 1 1 1 1 0]; %Unit response shifted by 1
unit to the left.
y = u1 + u2;
figure(1) % The function figure(h) makes the figure identified
by h the current figure, makes it visible, and raises it above all
other figures on the screen.
subplot(3,1,1),stem(n, u1 , 'filled')
title('x[n]')
subplot(3,1,2),stem(n, u2 , 'filled')
title('x[n+1]')
subplot(3,1,3),stem(n, y , 'filled')
title('y[n]')
%The last commands plot the discrete-time graphs in a single-plot.
OUTPUT
It can be seen that the system is not causal because at any value of n, we
need to know the input at the next value. For example y[5] = x[5] + x[6],
depends on future values.
c. Verify if the following system y[n] = x[2n] is time variant or invariant? Use a
signal of your choice.
CODE
r0 = [-6:6]; %The selected range.
i1 = [0, 0, 0, 0, 0, 0,1,1,1,1,1,1,1] %The input function.
r1 = [-3:3];%y = x[2*n], compresses the range of n by half.
i2 = [0,0,0,1,1,1,1] %The compressed input values (-3 to 3).
i3 = [0,0,1,1,1,1,0] %The input for y[n] = x[n] for comparison.
y = h; %Output for y[n] = x[n], comparator.
subplot(4,1,1), stem(r0,i1,'filled')
subplot(4,1,2), stem(r1,i2,'filled')
subplot(4,1,3),stem(r1,i3,'filled')
subplot(4,1,4),stem(r1,y,'filled')
OUTPUT
1.2Pre-Lab
Convolution is the process by which the output of a linear time invariant
system can be determined to a specific input signal. We shall cover
convolution in detail in the next lab. However, in this lab we shall only use
the convolution function provided in MATLAB. Use the convolution function
conv or convn to verify the following properties of systems.
d. Given the signals x[n] = [1 2 3 4 5] and y[n] = [1 1 1 1 1], verify using conv or
convn function that commutative property holds.
CODE
x = [1 2 3 4 5];
y = [1 1 1 1 1];
z = conv(x,y);
g = conv(y,x);
n2 = [-4:4]
subplot(2,1,1),stem(n2,z,'filled')
xlabel('h')
ylabel('z')
grid
subplot(2,1,2),stem(n2,g,'filled')
xlabel('h')
ylabel('g')
grid
OUTPUT
e. Assume a 2-D signal (i.e., some image). Load image and assume it to be signal x.
Next assume that instead of having a 2-D filter you have two one D filters h 1[n]
=[0.25 0.5 0.25] and h2[n]=[0.25;0.5;0.25]. Assume that the convolution (h1[n]*
h2[n]) = h3[n] = [0.0625 0.125 0.0625; 0.125 0.25 0.125; 0.0625
0.125 0.0625]. Using this information and output at each stage
verify that Associative property holds.
CODE
h2 = [0.25;0.5;0.25];
h3 = convn(h1,h2);
y = convn(x,h1);
output1 = convn(y,h2);
output2 = convn(h3,x);
subplot(211),imagesc(output1);
title('Graph of (x[n]*h1[n])*h2[n]');
subplot(212),imagesc(output2);