summaryrefslogtreecommitdiff
path: root/692/CH3/EX3.6/P3_6.sce
blob: c2d1f649ad2a9bf98b3adba1e4136bf9da4c46f3 (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
//EXAMPLE 3.6
//Determine DTFT of sequence
//PROGRAM REQUIRES MAXIMA SCILAB TOOLBOX

clc;
clear;
//Symbolic calculation
Syms n w a ;
x1=(a^n)*exp(-%i*n*w);
X1=nusum(x1,n,0,%inf);
disp(X1,'DFT,X = ');

//Given:
a=0.5;
n=0:9;
//x[n]=a^n*u[n]
for i = 0:9
    x(i+1) = a^i; 
end
//The DTFT of the sequence
K = 4;
k = 0:4/1000:4;
W = k*6*%pi/K;
X = (x')*exp(%i*n'*W);
X_mag   = abs(X);
[X_phase,db] = phasemag(X);

clf();
a=gca();
figure(0);
//Note %pi ~ 3.14
plot2d3(mtlb_fliplr(W),X_mag);
xtitle('Magnitude response','W --->','Amplitude --->');
figure(1);
plot2d3(mtlb_fliplr(W),X_phase);
xtitle('Phase response','W --->','Phase in degrees --->');