summaryrefslogtreecommitdiff
path: root/2279/CH7/EX7.3/Ex7_3.sce
blob: 310d1b57cb0239ee93462366922956eac0da27b8 (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
//DTFS of x[n] =2cos((pi/3)*n+(pi/6))
clear;
close;
clc;
n = -3:3;
N = 6;
Wo = 2*%pi/N;
xn = 2*cos((%pi/3)*n+(%pi/6));
//By euler's theorem X[n] can be represented 
x_n=exp(%i*(%pi*n/3)+%pi/6)+exp(-%i*(%pi*n/3)+%pi/6)
for i=1:length(n)
    if n(i)==1 
        a(i)=exp(%i*%pi/6);
    elseif n(i)==-1
        a(i)=exp(-%i*%pi/6);
    else
        a(i)=0;
    end
end
for i=1:length(a)
    if real(a(i))==0 then
        phase(i)=0;
    else
    phase(i)=atan(imag(a(i))/real(a(i)));
end
end
subplot(2,1,1)
plot2d3('gnn',n,abs(a))
xtitle("MAgnitude spectrum","k","|ak|")
subplot(2,1,2)
plot2d3('gnn',n,phase)
xtitle("Phase spectrum","k","angle(ak)")