This document presents a program to compute convolution using the overlap add and overlap save methods. It takes in an input signal, impulse response, and block length as input. It then performs convolution on the divided blocks and combines the results using overlap add or overlap save. Finally, it displays the input, impulse response, and output signal.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
39 views
DSP1
This document presents a program to compute convolution using the overlap add and overlap save methods. It takes in an input signal, impulse response, and block length as input. It then performs convolution on the divided blocks and combines the results using overlap add or overlap save. Finally, it displays the input, impulse response, and output signal.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5
Ex.
No: 01 CONVOLUTION BY OVERLAP ADD & SAVE METHOD 09L240
21-06-2011 09L242 09L243
PROGRAM CODE: clc; cleur ull; close ull;
%COMPUTATION OF CONVOLUTION BY OVERLAP ADD AND OVERLAP SAVE METHOD
ch= menu('CHOOSE A TYPE OF CONVOLUTION','1.OVERLAP ADD METHOD','2.OVERLAP SAVE METHOD');
x=lnput('Enter the lnput slgnul : '); %getting input signal n1= lnput('Enter the lower tlme lndex : '); h=lnput('Enter the lmpulse response of the system : '); %getting impulse response h1= lnput('Enter the lower tlme lndex : '); l=lnput('Enter the length of euch sectlon block : ');
t=length(x)+length(h)-1; %calculating length and matrix index ll1=length(x); m=length(h); n2= length(x)-1+n1; n= n1:n2; h2= length(h)-1+h1; z1=h1:h2; hf=h; h=[h zeros(1,l-1)]; h=h';r=[];xf=x;
swltch ch
cuse 1, %overlap add method
q=[]; d=[]; z=mod(ll1,l); lf(z-=0) x=[x zeros(1,l-z)]; %dividing into blocks end ll2=length(x); s=ll2/l;
for g=1:s Ex.No: 01 CONVOLUTION BY OVERLAP ADD & SAVE METHOD 09L240 21-06-2011 09L242 09L243
d=[d x(1:l)]; d=[d zeros(1,m-1)]; %padding zeros d=d'; for b=2:length(d) %generating toeplitz matrix d(1,b)=d(length(d),b-1); for c=2:length(d) d(c,b)=d(c-1,b-1); end;end; y=d*h; %performing convolution y=y'; r=[r y]; x=x(l+1:length(x)); d=[]; end l1=l; for z=1:s-1 for l=l+1:l+m-1 r(l)=r(l)+r(l1+m); %overlapping results and adding l1=l+1; end l1=l; lf(z==1) q=[q r(1:l+m-1)]; else q=[q r(m:l+m-1)]; end r=r(l+m:length(r)); %concatenating the results end q=[q r(m:l+m-1)]; r=q;
cuse 2, %overlap save method
x=[zeros(1,m-1) x zeros(1,10)]; %initial padding of zeros for s=1:15 d=x(1:l+m-1); %dividing into blocks Ex.No: 01 CONVOLUTION BY OVERLAP ADD & SAVE METHOD 09L240 21-06-2011 09L242 09L243
d=d'; for b=2:length(d) d(1,b)=d(length(d),b-1); %generating toeplitz matrix for c=2:length(d) d(c,b)=d(c-1,b-1); end; end; y=d*h; %performing convolution y=y'; r=[r y(m:length(y))]; %discarding m-1 elements x=x(l+1:length(x)); lf(dlff(x)==0) %concatenating the results breuk; end ; end; end; res=r(1:t); m1=n1+h1; m2=n2+h2; m=m1:m2; dlsp('THE INPUT SIGNAL IS : '); dlsp(xf); %displaying the inputs dlsp('THE IMPULSE RESPONSE IS : '); dlsp(hf); dlsp('THE OUTPUT SIGNAL IS : '); dlsp(res); %displaying the result subplot(3,1,1); %plotting the results stem(n,xf); xlubel('n'); ylubel('x[n]'); tltle('INPUT SIGNAL'); subplot(3,1,2); stem(z1,hf); xlubel('n'); ylubel('h[n]'); tltle('IMPULSE RESPONSE'); subplot(3,1,3); stem(m,res); xlubel('n'); ylubel('y[n]'); tltle('OUTPUT SIGNAL'); INPUT:
OVERLAP ADD METHOD:
Enter the lnput slgnul : [1 2 3 5 6 7 4 2 4 5 6] Enter the lower tlme lndex : 0 Enter the lmpulse response of the system : [3 4] Ex.No: 01 CONVOLUTION BY OVERLAP ADD & SAVE METHOD 09L240 21-06-2011 09L242 09L243
Enter the lower tlme lndex : 0 Enter the length of euch sectlon block : 4
THE INPUT SIGNAL IS : 1 2 3 5 6 7 4 2 4 5 6
THE IMPULSE RESPONSE IS : 3 4
THE OUTPUT SIGNAL IS : 3 10 17 27 38 45 40 22 20 31 38 24
OVERLAP SAVE METHOD:
Enter the lnput slgnul : [1 2 3 5 6 7 4 2 4 5 6] Enter the lower tlme lndex : 0 Enter the lmpulse response of the system : [3 4] Enter the lower tlme lndex : 0 Enter the length of euch sectlon block : 3
THE INPUT SIGNAL IS : 1 2 3 5 6 7 4 2 4 5 6
THE IMPULSE RESPONSE IS : 3 4
THE OUTPUT SIGNAL IS : 3 10 17 27 38 45 40 22 20 31 38 24
OUTPUT:
Ex.No: 01 CONVOLUTION BY OVERLAP ADD & SAVE METHOD 09L240 21-06-2011 09L242 09L243
1) - Once Again, It Is A Reworking of A Traditional Story Written by Fran Hunia and Illustrated by John Dyke. Yprovides An Outline of Its Language Content. - 220