ASSIGNMENT 1: Linear Convolution and De-Convolution
% Linear Convolution
x=[3 11 7 0 -1 4 2];
% input signal
h=[2 3 0 -5 2 1];
% impulse response
nx=[-3:3];
% beginning point and end point of x(n)
nh=[-1:4];
% beginning point and end point of h(n)
nyb=nx(1)+nh(1);
% beginning point of y(n)
nye=nx(length(x))+nh(length(h));
% end point of y(n)
ny=[nyb:nye]
% beginning point and end point of y(n)
y=conv(x,h)
% CONV(A, B) convolves vectors A and B.
% The resulting vector is length LENGTH(A)+LENGTH(B) - 1.
%Program for linear convolution of the sequence x(n) and h(n)
x=input('Enter the first sequence[ ]= ');
nx=input('Enter the beginning and end point of x(n)[ ]= ');
h=input('Enter the second sequence[ ]= ');
nh=input('Enter the beginning and end point of h(n)[ ]= ');
nyb=nx(1)+nh(1);
nye=nx(length(x))+nh(length(h));
ny=[nyb:nye]
y=conv(x,h)
%Program for linear convolution of the sequence x(n) and h(n)
x=input('Enter the first sequence[ ]= ');
nx=input('Enter the beginning and end point of x(n)[ ]= ');
h=input('Enter the second sequence[ ]= ');
nh=input('Enter the beginning and end point of h(n)[ ]= ');
nyb=nx(1)+nh(1);
nye=nx(length(x))+nh(length(h));
ny=[nyb:nye]
y=conv(x,h)
figure;
subplot(3,1,1);plot(x,nx);stem(x,nx);ylabel('Amplitude x(n)');xlabel('(a) n-->');
subplot(3,1,2);plot(h,nh);stem(h,nh);ylabel('Amplitude h(n)');xlabel('(b) n-->');
subplot(3,1,3);plot(y,ny);stem(y,ny);ylabel('Amplitude y(n)');xlabel('(c) n-->');
disp('The resultant signal is');y
The linear convolution has several properties:
x1(n) * x2(n) = x2(n) * x1(n)
: Commutation
[x1(n) * x2(n)]* x3(n) = x1(n) *[ x2(n)* x3(n)] : Association
x1(n) * [x2(n) + x3(n)] = x1(n) * x2(n) + x1(n)* x3(n) :Distribution
x1(n) = n[u(n + 5) u(n 5)]
x2(n) = cos(0.1n)[u(n) u(n 10)]
x3(n) = 1.2n [u(n + 5) u(n 5)]
(1)
(2)
Mathematically prove these properties.
Using Matlab M-file, generate and plot the following
sequences.
(a)
(b)
(c)
(d)
(e)
(f)
(3)
x1(n) = n[u(n + 5) u(n 5)]
x2(n) = cos(0.1n)[u(n) u(n 10)]
x3(n) = 1.2n [u(n + 5) u(n 5)]
y1(n) = x1(n) * x2(n)
y2(n) = x1(n) * x2(n)* x3(n)
y3(n) = x1(n) * x2(n) + x1(n)* x3(n)
Consider a system with impulse response
h(n) = (1/2)n ,
0<n<4
Using Matlab, determine the input x(n) for 0 < n < 8
that will generate the output sequence
y(n) = {1, 2, 2.5, 3, 3, 3, 2, 1}