summaryrefslogtreecommitdiff
path: root/1592/CH5/EX5.2/Example5_2.sce
blob: abb092a350694e002fdadb20f74fb945b20f5a7b (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
//Scilab Code for Example 5.2of Signals and systems by
//P.Ramakrishna Rao
//Discrete Time Fourier Transform of
//x[n]= 1 , 0=<n<=3
clear;
clc;
close;
// DTS Signal
N1 = 3;
n = 0:N1;
x = ones(1,length(n));
// Discrete-time Fourier Transform
Wmax = 2*%pi;       
K = 4;
k = 0:(K/1000):K;
W = k*Wmax/K;
XW = x* exp(-sqrt(-1)*n'*W);
XW_Mag = real(XW);
[XW_Phase,db] = phasemag(XW);
W = [-mtlb_fliplr(W), W(2:1001)]; // Omega from -Wmax to Wmax
XW_Mag = [mtlb_fliplr(XW_Mag), XW_Mag(2:1001)];
XW_Phase = [-mtlb_fliplr(XW_Phase),XW_Phase(2:1001)];
a = gca();
a.y_location ="origin";
a.x_location ="origin";
plot2d3('gnn',n,x);
xtitle('Discrete Time Sequence x[n]')
figure(1);
a = gca();
a.y_location ="origin";
a.x_location ="origin";
plot2d(W,abs(XW_Mag));
title('Discrete Time Fourier Transform X(exp(jW))')
figure(2);
a = gca();
a.y_location ="origin";
a.x_location ="origin";
plot2d(W,XW_Phase);
title('Phase Response <(X(jW))')