Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Title:-Compute & plot convolution sum of given signal.

%Program:
clc
clear all
close all
n=[0:1:5];
x=[2 8 9 -1 -3 12];
subplot(3,1,1)
stem(n,x)
xlabel('Time');
ylabel('Amplitude');
title('Discrete time Input signal x(n)')
h=[4 7 1

-2 -3 1];

subplot(3,1,2)
stem(n,h)
xlabel('Time');
ylabel('Amplitude');
title('Impulse response of system h(n)');
n1=[0:1:10];
y=conv(x,h);
subplot(3,1,3)
stem(n1,y)
xlabel('Time');
ylabel('Amplitude');
title('Convolution sum of x(n)and h(n)')
disp('Convolution sum of x(n)and h(n) is')
disp('y =')
disp(y)

Output:
Convolution sum of x(n)and h(n) is
y =

46

94

63

%Name: Ashirwad Padhee


%Roll no.:- T.E-Q-06
%Date:-14/08/2012

-32

-14

64

30

-16

-39

12

Title:- Verification of properties of convolution.

%Program:
clc
clear all
close all
n=[0:1:5];
x=[2 5 3 1 -4 2];
subplot(3,1,1)
stem(n,x)
xlabel('Time');
ylabel('Amplitude');
title('Discrete time Input signal x(n)')
h1=[6 9 3 5 1 2];
subplot(3,1,2)
stem(n,h1)
xlabel('Time');
ylabel('Amplitude');
title('Impulse response of system h1(n)');
h2=[-3 -2 1 4 5 7];
subplot(3,1,3)
stem(n,h2)
xlabel('Time');
ylabel('Amplitude');
title('Impulse response of system h2(n)');
n1=[0:1:10];
y=conv(x,h1);
n2=[0:1:15];
z=conv(y,h2);
figure;
stem(n2,z)
xlabel('Time');
ylabel('Amplitude');
title('(x(n)*h1(n))*h2(n)')
disp('(x(n)*h1(n))*h2(n) =')
disp(z)

w=conv(h1,h2);
q=conv(x,w)
figure;
stem(n2,q)
xlabel('Time');
ylabel('Amplitude');
title('x(n)*(h1(n)*h2(n))')
disp('x(n)*(h1(n)*h2(n)) =')
disp(q)

Output:

(x(n)*h1(n))*h2(n) =
151

-36 -168 -291


-29
42 -22

-216
28

142

607

856

833

537

253

121

142

607

856

833

537

253

121

x(n)*(h1(n)*h2(n)) =
151

-36 -168 -291 -216


-29
42
-22
28

Thus
x(n)*(h1(n)*h2(n)) = (x(n)*h1(n))*h2(n)
Hence, associative property is proved.

You might also like