summaryrefslogtreecommitdiff
path: root/3812/CH6/EX6.2/6_2.sce
diff options
context:
space:
mode:
authorprashantsinalkar2017-10-10 12:27:19 +0530
committerprashantsinalkar2017-10-10 12:27:19 +0530
commit7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 (patch)
treedbb9e3ddb5fc829e7c5c7e6be99b2c4ba356132c /3812/CH6/EX6.2/6_2.sce
parentb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (diff)
downloadScilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.gz
Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.bz2
Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.zip
initial commit / add all books
Diffstat (limited to '3812/CH6/EX6.2/6_2.sce')
-rw-r--r--3812/CH6/EX6.2/6_2.sce53
1 files changed, 53 insertions, 0 deletions
diff --git a/3812/CH6/EX6.2/6_2.sce b/3812/CH6/EX6.2/6_2.sce
new file mode 100644
index 000000000..1a7e5dcc8
--- /dev/null
+++ b/3812/CH6/EX6.2/6_2.sce
@@ -0,0 +1,53 @@
+//Example 6.2:
+//Discrete Time Fourier Transform of discrete sequence x[n]= (a^n).u[n], a>0 and a<0
+clear;
+clc;
+close;
+// DTS Signal
+a1 = 0.5;
+a2 = -0.5;
+max_limit = 10;
+for n = 0:max_limit-1
+ x1(n+1) = (a1^n);
+ x2(n+1) = (a2^n);
+end
+n = 0:max_limit-1;
+Wmax = 2*%pi;
+K = 4;
+k = 0:(K/1000):K;
+W = k*Wmax/K;
+x1 = x1';
+x2 = x2';
+XW1 = x1* exp(-sqrt(-1)*n'*W);
+XW2 = x2* exp(-sqrt(-1)*n'*W);
+XW1_Mag = abs(XW1);
+XW2_Mag = abs(XW2);
+W = [-mtlb_fliplr(W), W(2:1001)]; // Omega from -Wmax to Wmax
+XW1_Mag = [mtlb_fliplr(XW1_Mag), XW1_Mag(2:1001)];
+XW2_Mag = [mtlb_fliplr(XW2_Mag), XW2_Mag(2:1001)];
+[XW1_Phase,db] = phasemag(XW1);
+[XW2_Phase,db] = phasemag(XW2);
+XW1_Phase = [-mtlb_fliplr(XW1_Phase),XW1_Phase(2:1001)];
+XW2_Phase = [-mtlb_fliplr(XW2_Phase),XW2_Phase(2:1001)];
+figure
+subplot(3,1,1);
+plot2d3('gnn',n,x1);
+xtitle('Discrete Time Sequence x[n] for a>0')
+subplot(3,1,2);
+a = gca();
+a.y_location ="origin";
+a.x_location ="origin";
+plot2d(W,XW1_Mag);
+title('Magnitude Response abs(X(jW))')
+subplot(3,1,3);
+a = gca();
+a.y_location ="origin";
+a.x_location ="origin";
+plot2d(W,XW1_Phase);
+title('Phase Response <(X(jW))')
+//plot for a<0
+figure
+subplot(3,1,1);
+plot2d3('gnn',n,x2);
+xtitle('Discrete Time Sequence x[n] for a>0')
+subplot(3,1,2);