summaryrefslogtreecommitdiff
path: root/52/CH3/EX3.2/Example3_2.sce
blob: f927687fdd68111fca97d33eea015473838c2d81 (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
43
44
45
46
47
48
49
50
51
52
53
//Example 3.2
//Program to Compute the DFT of a Sequence x[n]=1, 0<=n<=2; and 0 otherwise
//for N=4 and N=8. Plot Magnitude and phase plots of each.
clear;
clc ;
close ;
//N=4
x1 = [1,1,1,0];
//DFT Computation
X1 = fft (x1 , -1);
//N=8
x2 = [1,1,1,0,0,0,0,0];
//DFT Computation
X2 = fft (x2 , -1);
//Display sequence X1[k] and X2[k] in command window
disp(X1,"X1[k]=");
disp(X2,"X2[k]=");
//Plots for N=4
n1=0:1:3;
subplot(2,2,1);
a = gca ();
a.y_location ="origin";
a.x_location ="origin";
plot2d3(n1,abs(X1),2);
poly1=a.children(1).children (1);
poly1.thickness=2;
xtitle('N=4','k','|X1(k)|');
subplot(2,2,2);
a = gca ();
a.y_location ="origin";
a.x_location ="origin";
plot2d3(n1,atan(imag(X1),real(X1)),5);
poly1=a.children(1).children (1);
poly1.thickness=2;
xtitle('N=4','k','<X1(k)');
//Plots for N=8
n2=0:1:7;
subplot(2,2,3);
a = gca ();
a.y_location ="origin";
a.x_location ="origin";
plot2d3(n2,abs(X2),2);
poly1=a.children(1).children (1);
poly1.thickness=2;
xtitle('N=8','k','|X2(k)|');
subplot(2,2,4);
a = gca ();
a.y_location ="origin";
a.x_location ="origin";
plot2d3(n2,atan(imag(X2),real(X2)),5);
poly1=a.children(1).children (1);
poly1.thickness=2;
xtitle('N=8','k','<X2(k)');