Auto AdSense

Friday, 19 September 2014

MATLAB code for Circular Convolution algorithm

clc;
clear all;
close all;
x=input('Enter the first Sequence');
h=input('Enter the second Sequence');
l=length(x);
m=length(h);
n=max(l,m);
x1=[x zeros(1,n-m)];
h1=[h zeros(1,n-l)];
for i=1:n
    sum=0;
    for k=1:n
        sum=sum+x1(k)*h1(mod(i-k,n)+1);
    end
    y(i)=sum;
end
disp(y)
p=cconv(x,h,n)
subplot(3,1,1)
stem(x1);
xlabel('time');ylabel('amplitude');title('First Sequence');
subplot(3,1,2)
stem(h1);
xlabel('time');ylabel('amplitude');title('Second Sequence');
subplot(3,1,3)
stem(y);
xlabel('time');ylabel('amplitude');title('Convoluted Sequence');

No comments:

Post a Comment