Lab Sheet 2
Lab Sheet 2
Report On
Familiarization with discrete-time LTI system
CRN = "017-311
Output:
1
1b
Source Code:
#Qno1 b#
x=[1,2,3,4];
nx=-1:2;
h=[2,3,4,5];
nh=-2:1;
n=nx(1)+nh(1):nx(end)+nh(end)
y=conv(x,h);
subplot(311)
stem(nx,x);
xlabel('n');
ylabel('x[n]');
title('signal: x[n]=[1,2,3,4] CRN - 017-311');
set(gca, "linewidth", 2, "fontsize", 20);
subplot(312)
stem(nh,h);
xlabel('n');
ylabel('h(n)');
title('signal:h[n]=[2,3,4,5] CRN - 017-311');
set(gca, "linewidth", 2, "fontsize", 20);
subplot(313)
stem(n,y);
xlabel('n');
ylabel('y[n]');
title('convolution of x[n] and h[n] CRN - 017-311');
set(gca, "linewidth", 2, "fontsize", 20);
Output:
2
2.LCCD Equation: Use MATLAB function filter() command to implement
following special system described by LCCD equation
a.A three-point smoothing filter :])2[]1[][(31y[n] nxnxnxb.The
differentiator: ]1[][y[n]nxnxc.The Accumulator: 1]-y[n][y[n]nxWrite
a MATLAB program that generates two sinusoidal signals x1 and x2
with relative frequencies f1 = 0.05 and f2 = 0.47. The two signals should be
added and the resultant signal x is applied to the three-point smoothing
digital filter. Plot the signals x1, x2, x and y in single figure using subplot.
a) solution
Source Code:
#Qno 2 a#
A=[1];
B=[1/3,1/3,1/3];
n=0:100;
f1=0.05;
f2=0.47;
x1=sin(2*pi*f1*n);
x2=sin(2*pi*f2*n);
x=x1+x2;
subplot(221);
plot(n,x1);
title('CRN - 017-311');
set(gca, "linewidth", 2, "fontsize", 20);
subplot(222);
plot(n,x2);
title('CRN - 017-311');
set(gca, "linewidth", 2, "fontsize", 20);
subplot(223);
plot(n,x);
title('CRN - 017-311');
set(gca, "linewidth", 2, "fontsize", 20);
y=filter(B,A,x);
subplot(224);
plot(n,y);
title('CRN - 017-311');
set(gca, "linewidth", 2, "fontsize", 20);
3
Output:
b) Solution
Source Code:
#Qno 2 b#
A=[1];
B=[1,-1];
n=0:100;
f=0.05;
x=sin(2*pi*f*n);
subplot(221);
plot(n,x);
title('CRN - 017-311');
set(gca, "linewidth", 2, "fontsize", 20);
y=filter(B,A,x);
subplot(222);
plot(n,y);
title('CRN - 017-311');
set(gca, "linewidth", 2, "fontsize", 20);
Output:
4
c) Solution
Source Code
#Qno 2 c#
B=[1];
A=[1,-1];
n=0:100;
f=0.05;
x=sin(2*pi*f*n);
subplot(2,2,1);
plot(n,x);
title('CRN - 017-311');
set(gca, "linewidth", 2, "fontsize", 20);
y=filter(B,A,x);
subplot(2,2,2);
plot(n,y);
title('CRN - 017-311');
set(gca, "linewidth", 2, "fontsize", 20);
Output
5
3.Impulse Response
Generate a unit impulse sequence and pass it through the three point
smoothing filter, the differentiator and the accumulator. Plot the impulse
responses of the systems.
A built-in MATLAB function impz helps to find and plot impulse response of
LTI system. Plot impulse response of the systems and compare the results
obtained in part i.
Source Code:
#Qno 3#
A=[1];
B=[1/3,1/3,1/3];
n=-20:20;
d=n==0;
stem(n,d);
y=filter(B,A,d);
plot(n,y);
title('CRN - 017-311');
set(gca, "linewidth", 2, "fontsize", 20);
Output:
6
4.Stability Test
Source Code:
#Qno 3#
function stabilityTest(b,a)
n = 0:100;
d = (n==0);
h = filter(b,a,d);
if abs(h(1))> abs(h(10))>abs(h(100))
disp('The system is stable')
else
disp('The system is unstable')
end
Output:
7
8