summaryrefslogtreecommitdiff
path: root/2279/CH7
diff options
context:
space:
mode:
authorprashantsinalkar2017-10-10 12:27:19 +0530
committerprashantsinalkar2017-10-10 12:27:19 +0530
commit7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 (patch)
treedbb9e3ddb5fc829e7c5c7e6be99b2c4ba356132c /2279/CH7
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 '2279/CH7')
-rw-r--r--2279/CH7/EX7.1/eg_7_1.sce23
-rw-r--r--2279/CH7/EX7.10/Ex7_10.sce22
-rw-r--r--2279/CH7/EX7.16/Ex7_16.sce32
-rw-r--r--2279/CH7/EX7.17/Ex7_17.sce32
-rw-r--r--2279/CH7/EX7.18/Ex7_18.sce27
-rw-r--r--2279/CH7/EX7.19/Ex7_19.sce25
-rw-r--r--2279/CH7/EX7.24/Ex7_24.sce22
-rw-r--r--2279/CH7/EX7.26/Ex7_26.sce36
-rw-r--r--2279/CH7/EX7.3/Ex7_3.sce32
-rw-r--r--2279/CH7/EX7.4/Ex7_4.sce30
-rw-r--r--2279/CH7/EX7.5/Ex7_5.sce23
-rw-r--r--2279/CH7/EX7.6/Ex7_6.sce23
-rw-r--r--2279/CH7/EX7.7/Ex7_7.sce23
-rw-r--r--2279/CH7/EX7.8/Ex7_8.sce31
-rw-r--r--2279/CH7/EX7.9/Ex7_9.sce31
15 files changed, 412 insertions, 0 deletions
diff --git a/2279/CH7/EX7.1/eg_7_1.sce b/2279/CH7/EX7.1/eg_7_1.sce
new file mode 100644
index 000000000..eb966be47
--- /dev/null
+++ b/2279/CH7/EX7.1/eg_7_1.sce
@@ -0,0 +1,23 @@
+//DTFS of x[n] =sin(Won)
+clear;
+close;
+clc;
+n = 0:0.01:5;
+N = 6;
+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:$)]
+k = -(N-2):(N-2);
+plot2d3('gnn',k,-imag(ak),5)
+plot2d3('gnn',N+k,-imag(ak),5)
+plot2d3('gnn',-(N+k),-imag(ak($:-1:1)),5)
+xtitle('ak','k','ak')
diff --git a/2279/CH7/EX7.10/Ex7_10.sce b/2279/CH7/EX7.10/Ex7_10.sce
new file mode 100644
index 000000000..67708d051
--- /dev/null
+++ b/2279/CH7/EX7.10/Ex7_10.sce
@@ -0,0 +1,22 @@
+//x[n] = 0.5+0.5*cos(2*%pi/N)n
+clear;
+close;
+clc;
+N = 8;
+n = 0:0.01:N;
+Wo = 2*%pi/N;
+xn =0.5*ones(1,length(n))+0.5*cos(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/2279/CH7/EX7.16/Ex7_16.sce b/2279/CH7/EX7.16/Ex7_16.sce
new file mode 100644
index 000000000..15079a5fb
--- /dev/null
+++ b/2279/CH7/EX7.16/Ex7_16.sce
@@ -0,0 +1,32 @@
+//Discrete Time Fourier Transform of discrete sequence
+//x[n]= (a^n).u[n], |a|<1
+clear;
+clc;
+close;
+a1 = 0.5;
+max_limit = 10;
+for n = 0:max_limit-1
+ x1(n+1) = (a1^n);
+end
+n = 0:max_limit-1;
+Wmax = 2*%pi;
+K = 4;
+k = 0:(K/1000):K;
+W = k*Wmax/K;
+x1 = x1';
+XW1 = x1* exp(-sqrt(-1)*n'*W);
+XW1_Mag = abs(XW1);
+W = [-mtlb_fliplr(W), W(2:1001)]; // Omega from -Wmax to Wmax
+XW1_Mag = 2.5*[mtlb_fliplr(XW1_Mag), XW1_Mag(2:1001)];
+[XW1_Phase,db] = phasemag(XW1);
+XW1_Phase = (1/30)*[-mtlb_fliplr(XW1_Phase),XW1_Phase(2:1001)];
+subplot(3,1,1);
+plot2d3('gnn',n,x1);
+xtitle('Discrete Time Sequence x[n]')
+subplot(3,1,2);
+plot2d(W,XW1_Mag);
+title('Magnitude Response abs(X(jW))')
+subplot(3,1,3);
+plot2d(W,XW1_Phase);
+title('Phase Response <(X(jW))')
+
diff --git a/2279/CH7/EX7.17/Ex7_17.sce b/2279/CH7/EX7.17/Ex7_17.sce
new file mode 100644
index 000000000..7a9b0c450
--- /dev/null
+++ b/2279/CH7/EX7.17/Ex7_17.sce
@@ -0,0 +1,32 @@
+//Discrete Time Fourier Transform of discrete sequence
+//x[n]= (a^n).u[-n], |a|>1
+clear;
+clc;
+close;
+a1 = 3;
+min_limit = -20;
+n = min_limit:0
+for i=1:length(n)
+ x1(i) = (a1^n(i));
+end
+Wmax = 2*%pi;
+K = 4;
+k = 0:(K/1000):K;
+W = k*Wmax/K;
+x1 = x1';
+XW1 = x1* exp(-sqrt(-1)*n'*W);
+XW1_Mag = abs(XW1);
+W = [-mtlb_fliplr(W), W(2:1001)]; // Omega from -Wmax to Wmax
+XW1_Mag = [mtlb_fliplr(XW1_Mag), XW1_Mag(2:1001)];
+[XW1_Phase,db] = phasemag(XW1);
+XW1_Phase = [-mtlb_fliplr(XW1_Phase),XW1_Phase(2:1001)];
+subplot(3,1,1);
+plot2d3('gnn',n,x1);
+xtitle('Discrete Time Sequence x[n]','n','x[n]')
+subplot(3,1,2);
+plot2d(W,XW1_Mag);
+xtitle('Magnitude Response abs(X(jW))','w','|X(jW)|')
+subplot(3,1,3);
+plot2d(W,XW1_Phase);
+xtitle('Phase Response <(X(jW))','w','<(X(jW))')
+
diff --git a/2279/CH7/EX7.18/Ex7_18.sce b/2279/CH7/EX7.18/Ex7_18.sce
new file mode 100644
index 000000000..de4954a80
--- /dev/null
+++ b/2279/CH7/EX7.18/Ex7_18.sce
@@ -0,0 +1,27 @@
+//Discrete Time Fourier Transform of
+//x[n]= (a^abs(n)) |a|<1
+clear;
+clc;
+close;
+// DTS Signal
+a = 0.5;
+max_limit = 10;
+n = -max_limit+1:max_limit-1;
+x = a^abs(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);
+plot2d3('gnn',n,x);
+xtitle('Discrete Time Sequence x[n] for a>0','n','x[n]')
+subplot(2,1,2);
+plot2d(W,XW_Mag);
+xtitle('Discrete Time Fourier Transform X(exp(jW))','w','|X(exp(jW))|')
diff --git a/2279/CH7/EX7.19/Ex7_19.sce b/2279/CH7/EX7.19/Ex7_19.sce
new file mode 100644
index 000000000..8d2c2918c
--- /dev/null
+++ b/2279/CH7/EX7.19/Ex7_19.sce
@@ -0,0 +1,25 @@
+//Discrete Time Fourier Transform of
+//x[n]= 1 , abs(n)&lt;=M1
+clear;
+clc;
+close;
+// DTS Signal
+M1 = 2;
+n = -M1:M1;
+x = ones(1,length(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)]; // Omega from -Wmax to Wmax
+XW_Mag = [mtlb_fliplr(XW_Mag), XW_Mag(2:1001)];
+//plot for abs(a)&lt;1
+figure
+subplot(2,1,1);
+plot2d3('gnn',n,x,2);
+xtitle('Discrete Time Sequence x[n]','n','x[n]')
+subplot(2,1,2);
+plot2d(W,XW_Mag);
+xtitle('Discrete Time Fourier Transform X(exp(jW))','w','|X(exp(jW))|') \ No newline at end of file
diff --git a/2279/CH7/EX7.24/Ex7_24.sce b/2279/CH7/EX7.24/Ex7_24.sce
new file mode 100644
index 000000000..c01faa4e7
--- /dev/null
+++ b/2279/CH7/EX7.24/Ex7_24.sce
@@ -0,0 +1,22 @@
+//Discrete Time Fourier Transform of
+// Periodic Impulse Train
+clear;
+clc;
+close;
+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)
+plot2d3('gnn',N1,x,2);
+xtitle('Periodic Impulse Train','n','x[n]')
+subplot(2,1,2)
+plot2d3('gnn',W,XW,2);
+xtitle('DTFT of Periodic Impulse Train','w','|X(exp(jw))|')
+disp(Wo)
diff --git a/2279/CH7/EX7.26/Ex7_26.sce b/2279/CH7/EX7.26/Ex7_26.sce
new file mode 100644
index 000000000..6aa35df4b
--- /dev/null
+++ b/2279/CH7/EX7.26/Ex7_26.sce
@@ -0,0 +1,36 @@
+//Discrete Time Fourier Transform of discrete sequence
+//x[n]= 1, n=2
+clear;
+clc;
+close;
+a1 = 1/8;
+max_limit = 10;
+for n = 0:max_limit-1
+ if n==2 then
+ x1(n+1) = 1;
+else
+ x1(n+1) = 0;
+end
+end
+n = 0:max_limit-1;
+Wmax = 2*%pi;
+K = 4;
+k = 0:(K/1000):K;
+W = k*Wmax/K;
+x1 = x1';
+XW1 = x1* exp(-sqrt(-1)*n'*W);
+XW1_Mag = abs(XW1);
+W = [-mtlb_fliplr(W), W(2:1001)]; // Omega from -Wmax to Wmax
+XW1_Mag = [mtlb_fliplr(XW1_Mag), XW1_Mag(2:1001)];
+[XW1_Phase,db] = phasemag(XW1);
+XW1_Phase = [-mtlb_fliplr(XW1_Phase),XW1_Phase(2:1001)];
+subplot(3,1,1);
+plot2d3('gnn',n,x1);
+xtitle('Discrete Time Sequence x[n]')
+subplot(3,1,2);
+plot2d(W,XW1_Mag);
+title('Magnitude Response abs(X(jW))')
+subplot(3,1,3);
+plot2d(W,XW1_Phase);
+title('Phase Response <(X(jW))')
+
diff --git a/2279/CH7/EX7.3/Ex7_3.sce b/2279/CH7/EX7.3/Ex7_3.sce
new file mode 100644
index 000000000..310d1b57c
--- /dev/null
+++ b/2279/CH7/EX7.3/Ex7_3.sce
@@ -0,0 +1,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)")
diff --git a/2279/CH7/EX7.4/Ex7_4.sce b/2279/CH7/EX7.4/Ex7_4.sce
new file mode 100644
index 000000000..85dbd8892
--- /dev/null
+++ b/2279/CH7/EX7.4/Ex7_4.sce
@@ -0,0 +1,30 @@
+//Fouries series representation of combinarion of signals
+//x[n]=1+sin(pi*n/2)+cos(%pi*n/4)
+clc
+clear
+close
+n=-3:3;
+x=1+sin(%pi*n/2)+cos(%pi*n/4);
+w1=%pi/2;
+w2=%pi/4;
+N1=2*%pi/w1;
+N2=2*%pi/w2;
+N=max(N1,N2);
+wo=2*%pi/N;
+//Expanding x[n] by Euler's theorem
+xn=1+0.5*exp(%i*wo*n)+0.5*exp(-%i*wo*n)-0.5*%i*exp(%i*2*wo*n)-0.5*%i*exp(-%i*2*wo*n);
+a0=1;
+a1=0.5;
+a_1=0.5;
+a2=1/2*%i;
+a_2=-1/2*%i;
+a=[a_2 a_1 a0 a1 a2];
+a1=[0 a 0];
+phase=[%pi/2 0 0 0 -%pi/2]
+phase=[0 phase 0]
+subplot(2,1,1)
+plot(n,abs(a1),'.')
+xtitle("magnitude spectrum","k","ak")
+subplot(2,1,2)
+plot(n,phase,'.')
+xtitle("Phase spectrum","k","ak")
diff --git a/2279/CH7/EX7.5/Ex7_5.sce b/2279/CH7/EX7.5/Ex7_5.sce
new file mode 100644
index 000000000..a1251bdb9
--- /dev/null
+++ b/2279/CH7/EX7.5/Ex7_5.sce
@@ -0,0 +1,23 @@
+//DTFS coefficients of periodic square wave
+clear;
+close;
+clc;
+N = 10;
+N1 = 2;
+Wo = 2*%pi/N;
+xn = ones(1,length(N));
+n = -(2*N1+1):(2*N1+1);
+a(1) = (2*N1+1)/N;
+for k =1:2*N1
+ a(k+1) = sin((2*%pi*k*(N1+0.5))/N)/sin(%pi*k/N);
+ a(k+1) = a(k+1)/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:$)];
+k = -2*N1:2*N1;
+plot2d3('gnn',k,abs(ak))
+xtitle('Magnitude spectrum','k','|ak|')
diff --git a/2279/CH7/EX7.6/Ex7_6.sce b/2279/CH7/EX7.6/Ex7_6.sce
new file mode 100644
index 000000000..c313d8a12
--- /dev/null
+++ b/2279/CH7/EX7.6/Ex7_6.sce
@@ -0,0 +1,23 @@
+//DTFS of a periodic sequence
+clc
+clear
+close
+n=-4:3;
+x=[0 1 2 3 0 1 2 3];
+N=4;
+k=0:3;;
+wo=2*%pi/N;
+a0=1.5;
+a1=-0.5+0.5*%i;
+a2=-0.5;
+a3=-0.5-0.5*%i;
+a=[a0,a1,a2,a3]
+for i=1:length(a)
+ phase(i)=atan(imag(a(i))/real(a(i)));
+end
+subplot(2,1,1)
+plot(k,abs(a),'.');
+xtitle("magnitude spectrum","k","ak");
+subplot(2,1,2)
+plot(k,phase,'.');
+xtitle("phase spectrum","k","ak");
diff --git a/2279/CH7/EX7.7/Ex7_7.sce b/2279/CH7/EX7.7/Ex7_7.sce
new file mode 100644
index 000000000..9e9508b5f
--- /dev/null
+++ b/2279/CH7/EX7.7/Ex7_7.sce
@@ -0,0 +1,23 @@
+//DTFS of discrete periodic signal
+clc
+clear
+close
+N=2//asume N=2
+n=-2*N:2*N
+for i=1:length(n)
+ if modulo(n(i),N)==0 then
+ x(i)=1;
+else
+ x(i)=0;
+end
+end
+subplot(2,1,1)
+plot(n,x,'.')
+xtitle("Input signal x[n]","n","x[n]");
+k=-5:5;
+for i=1:length(k)
+ ak(i)=1/N;
+end
+subplot(2,1,2)
+plot(k,ak,'.')
+xtitle("Frequency spectrum","k","ak")
diff --git a/2279/CH7/EX7.8/Ex7_8.sce b/2279/CH7/EX7.8/Ex7_8.sce
new file mode 100644
index 000000000..5257de458
--- /dev/null
+++ b/2279/CH7/EX7.8/Ex7_8.sce
@@ -0,0 +1,31 @@
+//x[n] = 1+sin(2*%pi/N)n+3cos(2*%pi/N)n+cos[(4*%pi/N)n+%pi/4]
+clear;
+close;
+clc;
+N = 10;
+n = 0:0.01:N;
+Wo = 2*%pi/N;
+xn =ones(1,length(n))+sin(Wo*n)+3*cos(Wo*n)+cos(2*Wo*n+%pi/4);
+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);
+for i = 1:length(a)
+ Phase_ak(i) = atan(imag(ak(i))/(real(ak(i))+0.0001));
+end
+Phase_ak = Phase_ak'
+Phase_ak = [Phase_ak(1:$-1) -Phase_ak($:-1:1)];
+k = -(N-2):(N-2);
+subplot(2,1,1)
+plot2d3('gnn',k,Mag_ak,5)
+xtitle('abs(ak)','k','ak')
+subplot(2,1,2)
+plot2d3('gnn',k,Phase_ak,5)
+xtitle('phase(ak)','k','ak')
diff --git a/2279/CH7/EX7.9/Ex7_9.sce b/2279/CH7/EX7.9/Ex7_9.sce
new file mode 100644
index 000000000..4f139a77f
--- /dev/null
+++ b/2279/CH7/EX7.9/Ex7_9.sce
@@ -0,0 +1,31 @@
+//x[n] = 1+sin(4*%pi/N)n+cos(10*%pi/N)n
+clear;
+close;
+clc;
+N = 21;
+n = 0:0.01:N;
+Wo = 2*%pi/N;
+xn =ones(1,length(n))+sin(2*Wo*n)+cos(5*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);
+for i = 1:length(a)
+ Phase_ak(i) = atan(imag(ak(i))/(real(ak(i))+0.0001));
+end
+Phase_ak = Phase_ak'
+Phase_ak = [Phase_ak(1:$-1) -Phase_ak($:-1:1)];
+k = -(N-2):(N-2);
+subplot(2,1,1)
+plot2d3('gnn',k,Mag_ak,5)
+xtitle('abs(ak)','k','ak')
+subplot(2,1,2)
+plot2d3('gnn',k,Phase_ak,5)
+xtitle('phase(ak)','k','ak')