summaryrefslogtreecommitdiff
path: root/40/CH8/EX8.5a/Exa_8_5a.sce
blob: 6e7a694df94cdc591789c704f5264caa20c0791c (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//properties of DFT
//a1)product
xn=[1 2 1 0];
XDFT=fft(xn,-1)
hn=xn.*xn
HDFT=fft(hn,-1)
HDFT1=1/4*(convol(XDFT,XDFT))
HDFT1=[HDFT1,zeros(8:12)];
HDFT2=[HDFT1(1:4);HDFT1(5:8);HDFT1(9:12)];
HDFT3=[0 0 0 0];
for i=1:4
    for j=1:3
        HDFT3(i)=HDFT3(i)+HDFT2(j,i);
    end
end
disp(HDFT3,'DFT of x[n]^2 is');
//a2)periodic convolution
vn=convol(xn,xn);
vn=[vn,zeros(8:12)];
vn=[vn(1:4);vn(5:8);vn(9:12)];
vn1=[0 0 0 0];
for i=1:4
    for j=1:3
        vn1(i)=vn1(i)+vn(j,i);
    end
end
VDFT=fft(vn1,-1);
VDFT1=XDFT.*XDFT;
disp(VDFT1,'DFT of x[n]*x[n] is');
//a3)signal energy(parcewell's theorem)
xn2=xn.^2;
E=0;
for i=1:length(xn2)
    E=E+abs(xn2(i));
end
XDFT2=XDFT.^2
E1=0;
for i=1:length(XDFT2)
    E1=E1+abs(XDFT2(i));
end
E,(1/4)*E1;
disp(1/4*E1,'The energy of the signal is');