Overlap Add Method: Input Input Input Input Modulo
Overlap Add Method: Input Input Input Input Modulo
Overlap Add Method: Input Input Input Input Modulo
clc
clear
disp('Consider longer sequence as x(n) and shorter one as h(n)');
l=input('Enter the number elements in x(n)');
x=input('Enter x1(n):');
N=input('Enter the number elements in h(n)');
h=input('Enter h(n):');
k=modulo(l,N);
if k~=0 then
for d=(1):N-k
x(l+d)=0;
end
end
L=length(x);
m=L/N;
M=L+N-1;
p=1;c=0;
Y=zeros(1,L+N-1);
H=[h,zeros(1,N-1)];
for a=1:m
x1=zeros(N);
j=1;
for b=p:p+N-1;
x1(j)=x(b);
j=j+1;
end
X=[x1',zeros(1,N-1)];
H1=fft(H);
X1=fft(X);
y=H1.*X1;
y1=fft(y,1);
p=p+N;
y2=circshift([y1,zeros(1,(m-1)*N)],c*N);
c=c+1;
Y=Y+y2;
end
disp('The linear convolution Y(n) is:');
disp(Y);