summaryrefslogtreecommitdiff
path: root/758/CH6/EX6.1/Ex_6_1.sce
blob: 3234ebc07c59e175595318e507d7f97aafe77b9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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=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): ');