From f35ea80659b6a49d1bb2ce1d7d002583f3f40947 Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Tue, 10 Oct 2017 12:38:01 +0530 Subject: updated the code --- 758/CH6/EX6.1/Ex_6_1.sce | 52 ++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 26 deletions(-) (limited to '758/CH6/EX6.1/Ex_6_1.sce') diff --git a/758/CH6/EX6.1/Ex_6_1.sce b/758/CH6/EX6.1/Ex_6_1.sce index 653fb1c54..3234ebc07 100755 --- a/758/CH6/EX6.1/Ex_6_1.sce +++ b/758/CH6/EX6.1/Ex_6_1.sce @@ -1,27 +1,27 @@ -//Example 6.1 -clc;clear;close; -x1=[1 1 2 2]; -x2=[1 2 3 4]; -ylength=length(x1); -//Calculation of linear convolution -z=convol(x1,x2); -//Calculation of circular convolution -for n=1:ylength - y(n)=0; - for k=1:ylength, - l=n-k+1; - if l <= 0 then - l=l+ylength; - end - y(n)=y(n)+(x1(k)*x2(l)); - end -end -//Calculation of circular convolution using DFT and IDFT -X1=dft(x1,-1); -X2=dft(x2,-1); -Y1=X1.*X2; -y1=dft(Y1,1); -y1=clean(y1); -disp(z,'Linear Convolution sequence is z(n): '); -disp(y,'Circular Convolution sequence is y(n): '); +//Example 6.1 +clc;clear;close; +x1=[1 1 2 2]; +x2=[1 2 3 4]; +ylength=length(x1); +//Calculation of linear convolution +z=convol(x1,x2); +//Calculation of circular convolution +for n=1:ylength + y(n)=0; + for k=1:ylength, + l=n-k+1; + if l <= 0 then + l=l+ylength; + end + y(n)=y(n)+(x1(k)*x2(l)); + end +end +//Calculation of circular convolution using DFT and IDFT +X1=fft(x1,-1); +X2=fft(x2,-1); +Y1=X1.*X2; +y1=fft(Y1,1); +y1=clean(y1); +disp(z,'Linear Convolution sequence is z(n): '); +disp(y,'Circular Convolution sequence is y(n): '); disp(y1,'Circular Convolution sequence calculated using DFT-IDFT method is y(n): '); \ No newline at end of file -- cgit