Sunday, 21 October 2012

Linear Convolution Using Cricular Convolution Method in MATLAB



Just create a two new file with extension .m and paste the code below in that .m file. Then Run it.

for circonv.m

function y = circonv(x,h)
l1=length(x);
%m1=length(h);
j=0;
for s=1:1:l1
    g(s)=0;
    j=j+1;
    for i=1:l1
        if j<1
            j=l1;
        end
        g(s)=g(s)+x(i)*h(j);


         i=i+1;
        j=j-1;
    end
end
y=g;
end


for  Linear_convoluton_from_circular_convolution.m

clear all;
clc;
x=input('Enter the sequence, x(n) : ' );
h=input('Enter the sequence, h(n) : ');
l=length(x);
m=length(h);
n=l+m-1;
x=[x,zeros(1,n-l)];
h=[h,zeros(1,n-m)];
z = circonv(x,h);
Final_Result=z;
Final_Result

No comments:

Post a Comment

Tech N Science © 2013