summaryrefslogtreecommitdiff
path: root/3812/CH6
diff options
context:
space:
mode:
Diffstat (limited to '3812/CH6')
-rw-r--r--3812/CH6/EX6.12/6_12.sce53
-rw-r--r--3812/CH6/EX6.13/6_13.sce53
-rw-r--r--3812/CH6/EX6.18/6_18.sce32
-rw-r--r--3812/CH6/EX6.19/6_19.sce16
-rw-r--r--3812/CH6/EX6.2/6_2.sce53
-rw-r--r--3812/CH6/EX6.20/6_20.sce23
-rw-r--r--3812/CH6/EX6.5/6_5.sce28
-rw-r--r--3812/CH6/EX6.6/6_6.sce30
8 files changed, 288 insertions, 0 deletions
diff --git a/3812/CH6/EX6.12/6_12.sce b/3812/CH6/EX6.12/6_12.sce
new file mode 100644
index 000000000..685e8c9e7
--- /dev/null
+++ b/3812/CH6/EX6.12/6_12.sce
@@ -0,0 +1,53 @@
+//Example 6_12:
+//Discrete Time Fourier Transform of discrete sequence x[n]=((-1)^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)=((-1)^n)*(a1^n);
+x2(n+1)=((-1)^n)*(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)];
+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);
diff --git a/3812/CH6/EX6.13/6_13.sce b/3812/CH6/EX6.13/6_13.sce
new file mode 100644
index 000000000..85911eeaa
--- /dev/null
+++ b/3812/CH6/EX6.13/6_13.sce
@@ -0,0 +1,53 @@
+//Example 6_13:
+//Discrete Time Fourier Transform of discrete sequence x[n]=(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)=(n)*(a1^n);
+x2(n+1)=(n)*(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)];
+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);
diff --git a/3812/CH6/EX6.18/6_18.sce b/3812/CH6/EX6.18/6_18.sce
new file mode 100644
index 000000000..1d404bb3d
--- /dev/null
+++ b/3812/CH6/EX6.18/6_18.sce
@@ -0,0 +1,32 @@
+//Example6.18:
+//Find and sketch the Fourier Transform
+clc;
+N = 5;
+N1 = -3*N:3*N;
+xn = [zeros(1,N-1),1];
+x = [1 xn xn xn xn xn xn];
+ak = 1/N;
+XW = 2*%pi*ak*ones(1,2*N);
+Wo = 2*%pi/N;
+n = -N:N-1;
+W = Wo*n;
+figure
+subplot(2,1,1)
+a = gca();
+a.y_location ="origin";
+a.x_location ="origin";
+plot2d3('gnn',N1,x,2);
+poly1 = a.children(1).children(1);
+poly1.thickness = 3;
+xlabel('n');
+title('Periodic Impulse Train')
+subplot(2,1,2)
+a = gca();
+a.y_location ="origin";
+a.x_location ="origin";
+plot2d3('gnn',W,XW,2);
+poly1 = a.children(1).children(1);
+poly1.thickness = 3;
+xlabel('W');
+title('DTFT of Periodic Impulse Train')
+disp(Wo)
diff --git a/3812/CH6/EX6.19/6_19.sce b/3812/CH6/EX6.19/6_19.sce
new file mode 100644
index 000000000..d7dbca228
--- /dev/null
+++ b/3812/CH6/EX6.19/6_19.sce
@@ -0,0 +1,16 @@
+//Example6.19:
+//Discrete Time Fourier Transform
+clc;
+N = 5;
+Wo = 2*%pi/N;
+W = [-Wo,0,Wo];
+XW =[%pi,0,%pi]; //figure
+a = gca();
+a.y_location ="origin";
+a.x_location ="origin";
+plot2d3('gnn',W,XW,2);
+poly1 = a.children(1).children(1);
+poly1.thickness = 3;
+xlabel('W');
+title('DTFT of cos(nWo)')
+disp(Wo)
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);
diff --git a/3812/CH6/EX6.20/6_20.sce b/3812/CH6/EX6.20/6_20.sce
new file mode 100644
index 000000000..1814d364b
--- /dev/null
+++ b/3812/CH6/EX6.20/6_20.sce
@@ -0,0 +1,23 @@
+//example 6_20
+//find the fourier transform of the periodic signal x[n] = cos(Wo)n
+clear;
+close;
+clc;
+N = 5;
+n = 0:0.01:N;
+Wo = 2*%pi/N;
+xn =sin(Wo*n);
+for k =0:N-2
+ C(k+1,:) = exp(sqrt(-1)*Wo*n.*k);
+ a(k+1) = xn*C(k+1,:)'/length(n);
+ if(abs(a(k+1))<=0.1)
+ a(k+1)=0;
+ end
+end
+a =a';
+a_conj =conj(a);
+ak = [a_conj($:-1:1),a(2:$)];
+Mag_ak = abs(ak);
+k = -(N-2):(N-2);
+plot2d3('gnn',k,Mag_ak,5)
+xtitle('abs(ak)','k','ak')
diff --git a/3812/CH6/EX6.5/6_5.sce b/3812/CH6/EX6.5/6_5.sce
new file mode 100644
index 000000000..eae33211b
--- /dev/null
+++ b/3812/CH6/EX6.5/6_5.sce
@@ -0,0 +1,28 @@
+//Example 6.5:
+//Find The Fourier Transform
+clc;
+a = 0.5;
+max_limit = 10;
+n = -max_limit+1:max_limit-1;
+x = a^abs(n);
+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);
+W = [-mtlb_fliplr(W), W(2:1001)];
+XW_Mag = [mtlb_fliplr(XW_Mag), XW_Mag(2:1001)];
+//plot for abs(a)<1
+figure
+subplot(2,1,1);
+a = gca();
+a.y_location ="origin";
+a.x_location ="origin";
+plot2d3('gnn',n,x);xtitle('Discrete Time Sequence x[n] for a>0')
+subplot(2,1,2);
+a = gca();
+a.y_location ="origin";
+a.x_location ="origin";
+plot2d(W,XW_Mag);
+title('Discrete Time Fourier Transform X(exp(jW))')
diff --git a/3812/CH6/EX6.6/6_6.sce b/3812/CH6/EX6.6/6_6.sce
new file mode 100644
index 000000000..07d4a2143
--- /dev/null
+++ b/3812/CH6/EX6.6/6_6.sce
@@ -0,0 +1,30 @@
+//Example 6.6:
+//Discrete Time Fourier Transform of
+clc;
+// DTS Signal
+N1 = 2;
+n = -N1: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);
+W = [-mtlb_fliplr(W), W(2:1001)]; // Omega from -Wmax to Wmax
+XW_Mag = [mtlb_fliplr(XW_Mag), XW_Mag(2:1001)];
+//plot for abs(a)<1
+figure
+subplot(2,1,1);
+a = gca();
+a.y_location ="origin";
+a.x_location ="origin";
+plot2d3('gnn',n,x);
+xtitle('Discrete Time Sequence x[n]')
+subplot(2,1,2);
+a = gca();
+a.y_location ="origin";
+a.x_location ="origin";
+plot2d(W,XW_Mag);
+title('Discrete Time Fourier Transform X(exp(jW))')