You are on page 1of 8

Name: NOOR UL AAIEN

Roll no: 2020 MC 35

LAB SESSION 7

TASK 1:
Use numerical convolution to evaluate the following:
a(t) = e−3t u(t); b(t) = e4tu(−t); c(t)= ∏ ( t/4); d(t) = t ∏ ( t/2)
t = 0.01;
starta = 0;
stopa = 1/2;
startb = 0;
stopb = 2;

% Define the time vectors for signals a(t) and b(t)


ta = starta:t:stopa;
a = exp(-3 * ta) .* (ta >= 0); % a(t) = e^(-3t) * u(t)
tb = startb:t:stopb;
b = exp(4 * tb) .* (tb >= 0); % b(t) = e^(4t) * u(-t)

I. w(t) = a(t) ∗ b(t)


tc = starta + startb:t:stopa + stopb;
c = t * conv(a, b);
subplot(411);
plot(ta, a);
title('a(t)');
xlabel('t');
ylabel('a(t)');

subplot(412);
plot(tb, b);
title('b(t)');
xlabel('t');
ylabel('b(t)');

subplot(413);
plot(tc, c(1:length(tc)));
title('Convolution: a(t) * b(t)');
xlabel('t');
ylabel('c(t)');
(t) = a(t) ∗ a(t)
% Evaluate and plot x(t) = a(t) * c(t)
x = dt * conv(a, a);
tx = (2 * starta):(2 * t):(2 * stopa);
subplot(414);
plot(tx, x(1:length(tx)));
title('Convolution: a(t) * a(t)');
xlabel('t');
ylabel('x(t)');
Task-2
Verify all the mathematical properties of convolution integral for the following
signals:
x[n]= e−2n ∗u[n−10]
h1[n]= 2−n ∗u[n+3]
h2[n]= 0.3n∗u[n−5]
Use subplot command to plot x[n],h1[n],h2[n], LHS and RHS results of each
property.
n = -10:20;

x = exp(-2 * n) .* (n >= 10);


h1 = 2 .^ (-n) .* (n >= -3);
h2 = 0.3 * n .* (n >= 5);

% Linearity Property
lhs1 = conv(x, (h1 + h2));
rhs1 = conv(x, h1) + conv(x, h2);

% Associative Property
lhs2 = conv(x, conv(h1, h2));
rhs2 = conv(conv(x, h1), h2);

% Distributive Property
lhs3 = conv(x, (h1 + h2));
rhs3 = conv(x, h1) + conv(x, h2);

% Time Invariance Property


tau = 2; % Delay
lhs4 = conv(x, h1);
rhs4 = conv(circshift(x, tau), h1);

% Plot all the signals and results


subplot(3, 2, 1);
plot(n, x,'r');
title('x[n]');

subplot(3, 2, 2);
plot(n, h1,'g');
title('h1[n]');

subplot(3, 2, 3);
plot(n, h2,'y');
title('h2[n]');

subplot(3, 2, 4);
plot(0:(length(lhs1) - 1), lhs1,'r');
title('LHS of Linearity Property');

subplot(3, 2, 5);
plot(0:(length(rhs1) - 1), rhs1,'b');
title('RHS of Linearity Property');

subplot(3, 2, 6);
plot(0:(length(lhs1) - 1), abs(lhs1 - rhs1),'c');
title('Difference (Linearity)');

figure;

subplot(3, 2, 1);
plot(0:(length(lhs2) - 1), lhs2,'m');
title('LHS of Associative Property');

subplot(3, 2, 2);
plot(0:(length(rhs2) - 1), rhs2,'b');
title('RHS of Associative Property');
subplot(3, 2, 3);
plot(0:(length(lhs2) - 1), abs(lhs2 - rhs2),'c');
title('Difference (Associative)');

subplot(3, 2, 4);
plot(0:(length(lhs3) - 1), lhs3,'r');
title('LHS of Distributive Property');

subplot(3, 2, 5);
plot(0:(length(rhs3) - 1), rhs3,'b');
title('RHS of Distributive Property');

subplot(3, 2, 6);
plot(0:(length(lhs3) - 1), abs(lhs3 - rhs3),'g');
title('Difference (Distributive)');

figure;

subplot(3, 2, 1);
plot(0:(length(lhs4) - 1), lhs4,'m');
title('LHS of Time Invariance Property');

subplot(3, 2, 2);
plot(0:(length(rhs4) - 1), rhs4,'r');
title('RHS of Time Invariance Property');

subplot(3, 2, 3);
plot(0:(length(lhs4) - 1), abs(lhs4 - rhs4),'y');
title('Difference (Time Invariance)');

You might also like