summaryrefslogtreecommitdiff
path: root/1592/CH5/EX5.16/Example5_16.sce
blob: dbc8282e7ba0b27d3b4364259bbe4686cd8393c0 (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
//Scilab Code for Example 5.16 of Signals and systems by
//P.Ramakrishna Rao
clc;
clear;
q=0;
x=[1,2,3,4];
w=0;
n=0:3;
z=(exp(-%i*w*n));
for n=0:3
    X(n+1)=z(n+1)*x(n+1);
    q=X(n+1)+q;
end
disp(q,'X(0)->zeroth DFT coefficient');
q=0;
w=%pi/2;
n=0:3;
z=(exp(-%i*w*n));
for n=0:3
    X(n+1)=z(n+1)*x(n+1);
    q=X(n+1)+q;
end
disp(q,'X(1)->first DFT coefficient');
q=0;
w=%pi;
n=0:3;
z=(exp(-%i*w*n));
for n=0:3
    X(n+1)=z(n+1)*x(n+1);
    q=X(n+1)+q;
end
disp(ceil(q),'X(2)->second DFT coefficient');
q=0;
w=3*%pi/2;
n=0:3;
z=(exp(-%i*w*n));
for n=0:3
    X(n+1)=z(n+1)*x(n+1);
    q=X(n+1)+q;
end
disp(q,'X(3)->third DFT coefficient');