Sunday, 21 October 2012
Circular Convolution (Overlap Add Without Function) in MATLAB
Just create a new file with extension .m and paste the code below in that .m file. Then Run it.
This will work for upto two sequence of signal.
clear all;
clc;
x=input('Enter the sequence x(n) : ');
h=input('Enter the sequence h(n) : ');
m=length(h);
n=2^m;
l=n-m+1;
x1=[x(1:l),zeros(1,m-1)];
x2=[x((l+1):(2*l)),zeros(1,m-1)];
hf=[h,zeros(1,n-m)];
First_Part=x1;
First_Part
Second_Part=x2;
Second_Part
Adjusted_response=hf;
Adjusted_response
l1=length(x1);
j=0;
for s1=1:1:l1
g1(s1)=0;
j=j+1;
for i=1:l1
if j<1
j=l1;
end
g1(s1)=g1(s1)+x1(i)*hf(j);
i=i+1;
j=j-1;
end
end
First_Part_Circular_convolution=g1;
First_Part_Circular_convolution
l2=length(x2);
j=0;
for s2=1:1:l2
g2(s2)=0;
j=j+1;
for i=1:l2
if j<1
j=l2;
end
g2(s2)=g2(s2)+x2(i)*hf(j);
i=i+1;
j=j-1;
end
end
Second_Part_Circular_convolution=g2;
Second_Part_Circular_convolution
last1=g1((l+1):n);
last2=g2(1:(m-1));
last_final=last1+last2;
final_circular_convolution=[g1(1:l),last_final,g2(((m-1)+1):(n-(m-1)))];
final_circular_convolution
at
14:18
Labels:
add,
circuit,
circular,
convolution,
electronics,
function,
language,
matlab,
overlap,
programming,
property,
theory,
windows
Posted by
Unknown
![](https://resources.blogblog.com/img/icon18_edit_allbkg.gif)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment