You are on page 1of 3

% B.

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

0.0010 0.0040 0.0100 0.0200 0.0350 0.0560 0.0840

Columns 8 through 14

0.1200 0.1560 0.1920 0.2280 0.2640 0.3000 0.3360

Columns 15 through 21

0.3720 0.4080 0.4440 0.4800 0.5160 0.5520 0.5880

1
Columns 22 through 28

0.6240 0.6600 0.6960 0.7320 0.7680 0.8040 0.8400

Columns 29 through 35

0.8760 0.9120 0.9480 0.9840 1.0200 1.0560 1.0920

Columns 36 through 42

1.1280 1.1640 1.2000 1.2360 1.2720 1.3080 1.3440

Columns 43 through 49

1.3800 1.4160 1.4520 1.4880 1.5240 1.5600 1.5960

Columns 50 through 56

1.6320 1.6170 1.5500 1.4300 1.2560 1.0270 0.7420

Column 57

0.4000

2
Published with MATLAB® R2016a

You might also like