Convolution Sum
Convolution Sum
WAGHOLI , PUNE SUBJECT: DIGITAL SIGNAL PROCESSING Experiment No: Date of Performance: Grade: Title: Convolution Sum Class: T.E (I sem) Signature:
AIM: To find response of discrete time system using convolution sum. THEORY : In mathematics and, in particular, functional analysis, convolution is
a mathematical operation on two functions f and g, producing a third function that is typically viewed as a modified version of one of the original functions, giving the area overlap between the two functions as a function of the amount that one of the original functions is translated. Convolution is similar to cross-correlation. It has applications that
processing, electrical
The convolution of f and g is written fg, using an asterisk or star. It is defined as the integral of the product of the two functions after one is reversed and shifted. As such, it is a particular kind of integral transform:
(commutativity) While the symbol t is used above, it need not represent the time domain. But in that context, the convolution formula can be described as a weighted average of the function f() at the moment twhere the weighting is given by g() simply shifted by amount t. As t changes, the weighting function emphasizes different parts of the input function
ALGORITHM: A) USING INBUILT FUNCTION: 1)Start. 2)Enter the input sequence x(n) and impulse response h(n) 3)Calculate the length of x(n) and h(n) i.e l and m resp. using function length(). 4)Initialize two arrays from 0:L-1. 5) Perform the convolution sum operation of input sequence and impulse response using inbuilt function conv2. 6)Display the output of convolution sum. 7)Plot the input sequence , impulse response and convolution sum. 8)End. B) USING LOGIC 1) Start 2)Enter the input sequence x(n) and impulse response h(n) 3)Calculate the length of x(n) and h(n) and store it in L and m resp.. 4)Initialize two arrays L and m from 0:m-1. 5)Initialize y to be zero. 6) Using for loop forn=1 to L+m-1 and for loop for k=1 to L. 7)Check conditions in the for loop as (n-k)>0 and (n-k),m. 8)if the conditions are satisfied then, y(n)= y(n)+[x(k)*h(n-k+1)] 9)Repeat for all the values of k and n 10)Display the result. PROCEDURE: Open MATLAB Open new M-file Type the program Save in current directory Compile and Run the program For the output see command window\ Figure window
CONCLUSION: Hence , we have successfully performed the convolution sum operation for an LTI system and have observed the convolved output for a given input and impulse response and have verified it practically. MATLAB CODE % Program to find the output of an LTI system for given input from its % impulse response. clc; disp('Program to find output of an LTI system for given input from its impulse response') x=input('Enter the value of the input for LTI system:: '); h=input('Enter the value of the impulse response for the LTI system:: '); subplot(4,1,1); stem(x); ylabel('AMP'); title('INPUT'); subplot(4,1,2); stem(h); ylabel('AMP'); title('IMPULSE RESPONSE'); %Program to find the putput of an LTI system using in-built functions. y=conv2(x,h); disp('Output of the convolution of the above two signals using in-built functions is') disp(y) subplot(4,1,3); stem(y) ylabel('AMP'); title('OUTPUT USING INBUILT FUNCTIONS'); %Program to find the output of an LTI system using logic. l=length(x); m=length(h); n=l+m-1; z=zeros(1,n); for i=1:n for k=1:l if((i-k)>=0 & (i-k)<m) z(i)=z(i)+(x(k)*h(i-k+1)); end end end
disp('Output of the convolution of the above two signals using logic is'); disp(z) subplot(4,1,4); stem(z) ylabel('AMP'); title('OUTPUT USING LOGIC'); COMMAND WINDOW OUTPUT:: Program to find output of an LTI system for given input from its impulse response Enter the value of the input for LTI system:: [1 2 3 4] Enter the value of the impulse response for the LTI system:: [1 2 2] Output of the convolution of the above two signals using in-built functions is 1 4 9 14 14 8 Output of the convolution of the above two signals using logic is 1 4 9 14 14 8 FIGURE WINDOW