Blogger Widgets

Wednesday, 18 April 2012

Sectional convolution using overlap saving method :-

Function for Circular convolution:-


function y=mycirconv(x,h)
lx=length(x);
lh=length(h);
l=max(lx,lh);
X=[x zeros(1,l-lx)];
H=zeros(l);
H(1:lh)=h;
for j=1:l-1
for i=1:l-1
H(i+1,j+1)=H(i,j);
end
H(1,j+1)=H(l,j);
end
y=H*X';

 Main program:-

 clc;
clear all;
close all;
x=input('Enter x(n) :');
h=input('Enter h(n) :');
N=input('Enter Block length N =');
subplot(2,2,1);
stem(x);
title('1st sequence x(n)');
subplot(2,2,2);
stem(h);
title('2nd sequence h(n)');
lx=length(x);
lh=length(h);
m=lh-1;
x=[zeros(1,m) x zeros(1,N-1)];
h=[h zeros(1,N-lh)];
L=N-lh+1;
k=floor((lx+lh-1)/L);
for i=0:k
y=x(1,i*L+1:i*L+N);
q=mycirconv(y,h);
p(i+1,:)=q;
end
p1=p(:,lh:N)';
p=p1(:)'
subplot(2,2,3:4);
stem(p);
title('Sectional Convolution using Overlap Save method');

0 comments

Post a Comment