0% found this document useful (0 votes)
5 views7 pages

Exp 3

The document outlines an experiment focused on implementing linear convolution to analyze discrete time LTI systems using MATLAB. It includes theoretical explanations, step-by-step procedures for performing convolution, and practical MATLAB code examples with outputs. Additionally, it discusses learning outcomes such as computing convolution for discrete-time signals and understanding properties of LTI systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views7 pages

Exp 3

The document outlines an experiment focused on implementing linear convolution to analyze discrete time LTI systems using MATLAB. It includes theoretical explanations, step-by-step procedures for performing convolution, and practical MATLAB code examples with outputs. Additionally, it discusses learning outcomes such as computing convolution for discrete-time signals and understanding properties of LTI systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

23102107 Saniya Walavalkar

Experiment-3
Objective: Explain the implementation of linear convolution as an operation to analyze
discrete time LTI system using MATLAB functions.

Theory: Consider two finite duration sequences x (n) and h (n), the duration of x (n) is
n1 samples in the interval 0 n (n1 −1) . The duration of h (n) is n2 samples; that is h
(n) is non – zero only in the interval 0 n (n2 −1) . The linear or a periodic convolution
of x (n) and h (n) yields the sequence y (n) defined as,

Clearly, y (n) is a finite sequence of duration (n1+n2 -1) samples.


The convolution sum of two sequences can be found by using following steps:

Step1: Choose an initial value of n, the starting time for evaluating the output sequence
y (n). If x (n) starts at n=n1 and h (n) starts at n= n2 then n = n1+ n2-1 is a good
Choice.

Step2: Express both sequences in terms of the index m.

Step3: Fold h (m) about m=0 to obtain h (-m) and shift by n to the right if n is positive and
left if n is negative to obtain h (n-m).

Step4: Multiply two sequences x (n-m) and h (m) element by element and sum the
products to get y (n).

Step5: Increment the index n, shift the sequence x (n-m) to right by one sample and repeat
Step4.

Step6: Repeat step5 until the sum of products is zero for all remaining values of n.
23102107 Saniya Walavalkar

IN LAB EXERCISES:

Q1
a)
x = [1, 3, -2, 1];
h = [1, 1, 0, 0];
n_start = 0;
n_length = length(x) + length(h) - 1;
y = zeros(1, n_length);
for n = 1:n_length
y(n) = 0;
for m = 1:length(h)
if (n-m+1 >= 1)&& (n-m+1 <= length(x))
y(n) = y(n) + x(n-m+1) * h(m);
End end end
disp('Convolution of x[n] and h[n]:');
disp(y);
stem(0:n_length-1,y,'filled','red');
grid on;
title("23102107")
xlabel("n --->");
ylabel("y --------->");

OUTPUT:
Convolution of x[n] and h[n]:
1 4 1 -1 1 0 0

Convolution of x[n] and h[n] using conv:


1 4 1 -1 1 0 0
23102107 Saniya Walavalkar

b)
x = [1, 1, 1, 0 ,0 , 0];
h = [0.5, 2, 2.5, 1];
n_start = 0;
n_length = length(x) + length(h) - 1;
y = zeros(1, n_length);
for n = 1:n_length
y(n) = 0;
for m = 1:length(h)
if (n-m+1 >= 1) && (n-m+1 <= length(x))
y(n) = y(n) + x(n-m+1) * h(m);
end End end
disp('Convolution of x[n] and h[n]:');
disp(y);
y1 = conv(x, h);
disp('Convolution of x[n] and h[n] using conv:');
disp(y1);
stem(0:n_length-1,y,'filled','red');
grid on;
title("23102107")
xlabel("n --->");
ylabel("y --------->");

OUTPUT :
Convolution of x[n] and h[n]:
0.5000 2.5000 5.0000 5.5000 3.5000 1.0000 0 0
0

Convolution of x[n] and h[n] using conv:


0.5000 2.5000 5.0000 5.5000 3.5000 1.0000 0 0
0
23102107 Saniya Walavalkar

C)
a = 0.5;
n = 0:20;
x = ones(1, length(n));
h = exp(-a * n);
n_start = 0;
n_length = length(x) + length(h) - 1;
y = zeros(1, n_length);
for n = 1:n_length
y(n) = 0;
for m = 1:length(h)
if (n-m+1 >= 1) && (n-m+1 <= length(x))
y(n) = y(n) + x(n-m+1) * h(m);
end
end
end
disp('Convolution of x[n] and h[n]:');
disp(y);
y1 = conv(x, h);
disp('Convolution of x[n] and h[n] using conv:');
disp(y1);
stem(0:n_length-1, y, 'filled', 'red');
grid on;
title('23102107');
xlabel('n --->');
ylabel('y[n] --------->');
Output:

Convolution of x[n] and h[n]:


Columns 1 through 17

1.0000 1.6065 1.9744 2.1975 2.3329 2.4150 2.4647 2.4949


2.5133 2.5244 2.5311 2.5352 2.5377 2.5392 2.5401 2.5406
2.5410

Columns 18 through 34

2.5412 2.5413 2.5414 2.5414 1.5414 0.9349 0.5670 0.3439


0.2085 0.1265 0.0767 0.0465 0.0282 0.0171 0.0103 0.0062
0.0038

Columns 35 through 41

0.0022 0.0013 0.0008 0.0004 0.0002 0.0001 0.0000

Convolution of x[n] and h[n] using conv:


Columns 1 through 17

1.0000 1.6065 1.9744 2.1975 2.3329 2.4150 2.4647 2.4949


2.5133 2.5244 2.5311 2.5352 2.5377 2.5392 2.5401 2.5406
2.5410
23102107 Saniya Walavalkar

Columns 18 through 34

2.5412 2.5413 2.5414 2.5414 1.5414 0.9349 0.5670 0.3439


0.2085 0.1265 0.0767 0.0465 0.0282 0.0171 0.0103 0.0062
0.0038

Columns 35 through 41

0.0022 0.0013 0.0008 0.0004 0.0002 0.0001 0.0000

Q2

f1 = [1, 0, 0, 0, 0];
f2 = [1, 1, 1];
f3 = [1, 1, 1, 0, 0];
y1 = conv(f1, f2);
y2 = conv(f2, f1);
disp("(a) f1[n]*f2[n]=f2[n]*f1[n]")
disp(y1);
disp(y2);
max_len = max(length(f2), length(f3));
f2padded = padarray(f2, [0, max_len - length(f2)], 'post');
f3padded = padarray(f3, [0, max_len - length(f3)], 'post');
f2plusf3 = f2padded + f3padded;
disp("(b) f1[n]*(f2[n]+f3[n])= f1[n]*f2[n] + f1[n]*f2[n]")
23102107 Saniya Walavalkar

disp(conv(f1, f2plusf3));
y3=conv(f1,f2);
y4=conv(f1,f3);
max_len = max(length(y3), length(y4));
y3padded = padarray(y3, [0, max_len - length(y3)], 'post');
y4padded = padarray(y4, [0, max_len - length(y4)], 'post');
y3plusy4 = y3padded + y4padded;
disp(y3plusy4);
disp("(c) f1[n]*(f2[n]*f3[n])=(f1[n]*f2[n])*f3[n]")
Y=conv(f2,f3);
disp(conv(y1,f3));
disp(conv(f1,Y));
disp("23102107");
Output:
(a) f1[n]*f2[n]=f2[n]*f1[n]
1 1 1 0 0 0 0

1 1 1 0 0 0 0

(b) f1[n]*(f2[n]+f3[n])= f1[n]*f2[n] + f1[n]*f2[n]


2 2 2 0 0 0 0 0 0

2 2 2 0 0 0 0 0 0

(c) f1[n]*(f2[n]*f3[n])=(f1[n]*f2[n])*f3[n]
1 2 3 2 1 0 0 0 0 0 0

1 2 3 2 1 0 0 0 0 0 0

23102107

POST LAB EXERCISE:

Q1
n = 0:20;
x = [1, zeros(1, length(n)-1)];
h1 = ones(1, length(n));
h2 = [ones(1, 5), zeros(1, length(n)-5)];
w = conv(x, h1);
y1 = conv(w, h2);
g = conv(h1, h2);
y2 = conv(x, g);
subplot(3,1,1);
stem(0:length(y1)-1, y1, 'filled');
title('y[n] = w[n] * h2[n] (Part a) - 23102107');
xlabel('n');
ylabel('y[n]');
subplot(3,1,2);
stem(0:length(y2)-1, y2, 'filled');
title('y[n] = x[n] * g[n] (Part b) - 23102107');
23102107 Saniya Walavalkar

xlabel('n');
ylabel('y[n]');
subplot(3,1,3);
stem(0:length(g)-1, g, 'filled');
title('g[n] = h1[n] * h2[n] - 23102107');
xlabel('n');
ylabel('g[n]');

LEARNING OUTCOMES :

1. Learned to compute convolution for discrete-time signals both manually and


using MATLAB.
2. Understood how LTI systems process signals and how cascaded systems
work.
3. Demonstrated properties like commutativity and associativity of convolution.

You might also like