x1=input('enter the first sequence')
x2=input('enter the second seqquence')
N1=length(x1)
N2=length(x2)
if N1>N2
x2=[x2,zeros(N2-N1)] %padding zeros to make lengths of two sequences equal
end
if N2>N1
x1=[x1,zeros(N2-N1)]
end
N=max(N1,N2)
X1=fft(x1,N);
X2=fft(x2,N);
X3=X1.*X2
x3=ifft(X3)
subplot(2,2,1);
stem(x1);
xlabel('n---->');
ylabel('amplitude');
title('first sequence');
subplot(2,2,2)
stem(x2)
xlabel('n---->');
ylabel('amplitude');
title('second sequence');
subplot(2,2,3)
stem(x3)
xlabel('n----->');
ylabel('amplitude');
title('circular convolution');
x2=input('enter the second seqquence')
N1=length(x1)
N2=length(x2)
if N1>N2
x2=[x2,zeros(N2-N1)] %padding zeros to make lengths of two sequences equal
end
if N2>N1
x1=[x1,zeros(N2-N1)]
end
N=max(N1,N2)
X1=fft(x1,N);
X2=fft(x2,N);
X3=X1.*X2
x3=ifft(X3)
subplot(2,2,1);
stem(x1);
xlabel('n---->');
ylabel('amplitude');
title('first sequence');
subplot(2,2,2)
stem(x2)
xlabel('n---->');
ylabel('amplitude');
title('second sequence');
subplot(2,2,3)
stem(x3)
xlabel('n----->');
ylabel('amplitude');
title('circular convolution');
No comments:
Post a Comment