<-- back to Lab Page

Lab 5: Discrete Time Convolution

( view Lab Instructions and Requirements )

Aim: To compare the discrete time convolution obtained experimentally in Simulink to the computions obtained theoretically using Matlab algorithms.

x[n] is a discrete sine wave with frequency 0.2*pi and Sample time of 1 second.

h[n], the impulse response function is = [1 2 3 4 5 4 3 2 1].

So, y[n] = x[n] * h[n]-- (convolution)

Results

Experimental

The convolution is carried out by a Discrete Transfer Function object.

x[n]

y[n]

Theoretical I

The following matlab code was used to generate the first theoretical plot:

---------------disc_conv1.m---------------

h = [1 2 3 4 5 4 3 2 1];
x = sin(0.2*pi*[0:20]);
y = conv(h, x);

figure(1)
stem (x);
title('Discrete Filter Input x[n]');
xlabel('index, n')
ylabel('Value, x[n]')

figure (2)
stem(y);
title('Discrete Filter Output y[n]');
xlabel('index, n')
ylabel('Value, y[n]')
------------------------------------------

This first algorithm uses the conv function to produce the y values. Even though there are only 21 points in the x array, the conv function produces 8 more points because it uses the convolution summation and assumes that x[n] = 0 when n>20.

Theoretical II

The following matlab code was used to generate the second theoretical plot:

---------------disc_conv2.m---------------

h = [1 2 3 4 5 4 3 2 1];
x = sin(0.2*pi*[0:20]);

N = 9;
x_n = zeros(N,1); %create shift register

for n = 0:20
x_n(2:N) = x_n(1:N-1); %shift first N-1 values by 1
x_n(1) = x(n+1); %shift in next value of x
y(n+1) = h*x_n; %convolution sum
end

figure(3)
stem (y);
title('Discrete Filter Output y[n]');
xlabel('index, n')
ylabel('Value, y[n]')

------------------------------------------

This method uses a shift register to cycle through all the values of x. In each cycle of the loop, the next x value is 'shifted' into the shift register and all the x values are multiplied with the corresponding h values. Then the products are summed to form the y value for that time. This summation happens as part of the matrix multiplication because h is 1 by N and the shift register x_n is N by 1. Recall that the convolution sum is given by:

Sum {m=-Infinity to Infinity} h[n-m]x[m]

When m<0, x[m] is 0.

At m=0, the first value of x is moved into the register and the product of h and x_n is equivalent to x[0].h[0] which is y[0]. When m=1, the values in the shift register are shifted by one and the next value of x is shifted into the starting position in x_n. The ensuing product is equivalent to h[0].x[1] + h[1].x[0] etc.

The plot of y is shown below:

Conclusion

After a point by point comparisom of the graphs obtained experimentally and the two theoretical graphs for y[n], it should be apparent that all the methods produced the same result.

Web Design: © 2001 Nathaniel Ayewah natayewah@hotmail.com
Last Updated: November 20, 2001