0% found this document useful (0 votes)
15 views9 pages

Lab Sheet 2

Uploaded by

ashutoshjak88
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views9 pages

Lab Sheet 2

Uploaded by

ashutoshjak88
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Nepal Engineering College

(Affiliated to POKHARA UNIVERSITY)


Changunarayan, Bhaktapur

Report On
Familiarization with discrete-time LTI system

SUBMITTED BY: SUBMITTED TO:


Name: Ashutosh Acharya Rupesh D. Shrestha Sir
Roll No: 017-311
Department: Computer – 1
Group - A
1.Convolution Sum The convolution of two discrete-time signals can be
found using the MATLAB command conv. This command helps to find the
convolution of two causal signals.
a.Find the convolution of the two signals x1(n)={1,2,3,4} and x2(n)={2,3,4,5}
and plot the result of the convolution.
b.Write a user defined function to calculate convolution of two non-causal
discrete-time signals. [hint: Define the time index for x1[n] and x2[n], and
calculate the convolution and time index]
1a
Source Code
#Qno1 a#
x1=[1,2,3,4];
x2=[2,3,4,5];
y=conv(x1,x2)

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]nxWrite
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

You might also like