MATLAB : Convolution Using DFT

Q:1. Find the linear convolution of the sequences S1(n) = {1, -2,-2, 1} and S2(n) = {-1, 1, 1, -1}; Verify the result using convolution property. 

clc;
x1=input('x1 : ');
x2=input('x2 : ');
x=conv(x1,x2);
subplot(211);
stem(x);
title('Answer using direct convelution');
n=length(x1)+length(x2)-1;
X1=fft(x1,n);
X2=fft(x2,n);
X=X1.*X2;
xc=ifft(X,n);
subplot(212);
stem(xc);
title('Answer using DFT method');

0 comments: