Professional Documents
Culture Documents
Tech, ECE
%--------------------------------------------------------------------------
% AIM:-Overlap and Add method
%--------------------------------------------------------------------------
close all
clear all
clc
x=[1:50];
h=[1:8];
N=10;
lx=length(x);
m=length(h);
p=N-m+1;
z=conv(x,h);
subplot(2,1,1);
stem(z,'LineWidth',2);
title('Convolution of X and H');
r=rem(lx,N);
x=[x,zeros(1,lx-r)];
h=[h,zeros(1,N-m)];
k=floor((lx+m-1)/p);
y=zeros(k,N);
for i=0:k-1
a=x((p*i+1):p+p*i);
b=[a,zeros(1,m-1)];
y(i+1,:)=cconv(b,h,N);
end
for j=2:k
y(j,1:m-1)=y(j,1:m-1)+y(j-1,(1+p):N);
end
y=y(:,1:p)';
y=(y(:))';
disp(y)
z=conv(x,h);
subplot(2,1,2);
stem(y,'LineWidth',2);
title('Linear convolution by overlap add method');
%End of Program
1.0e+03 *
Columns 1 through 7
Columns 8 through 14
Columns 15 through 21
1
Columns 22 through 28
Columns 29 through 35
Columns 36 through 42
Columns 43 through 49
Columns 50 through 56
Column 57
0.4000
2
Published with MATLAB® R2016a