summaryrefslogtreecommitdiff
path: root/716/CH9
diff options
context:
space:
mode:
Diffstat (limited to '716/CH9')
-rwxr-xr-x716/CH9/EX9.1.III/9_11_ShortQnA_9_1.sce21
-rwxr-xr-x716/CH9/EX9.1/Solved_Ex9_1.sce41
-rwxr-xr-x716/CH9/EX9.2.III/9_11_ShortQnA_9_2.sce21
-rwxr-xr-x716/CH9/EX9.2.V/9_13_ExerciseV9_2.sce21
-rwxr-xr-x716/CH9/EX9.2.m/MatLab_Prog9_2.sce24
-rwxr-xr-x716/CH9/EX9.2/Solved_Ex9_2.sce16
-rwxr-xr-x716/CH9/EX9.3.V/9_13_ExerciseV9_3.sce21
-rwxr-xr-x716/CH9/EX9.3/Solved_Ex9_3.sce21
-rwxr-xr-x716/CH9/EX9.4.V/9_13_ExerciseV9_4.sce21
-rwxr-xr-x716/CH9/EX9.5.m/MatLab_Prog9_5.sce21
-rwxr-xr-x716/CH9/EX9.5/Solved_Ex9_5.sce16
-rwxr-xr-x716/CH9/EX9.6/Solved_Ex9_6.sce25
-rwxr-xr-x716/CH9/EX9.7/Solved_Ex9_7.sce25
13 files changed, 294 insertions, 0 deletions
diff --git a/716/CH9/EX9.1.III/9_11_ShortQnA_9_1.sce b/716/CH9/EX9.1.III/9_11_ShortQnA_9_1.sce
new file mode 100755
index 000000000..d81d75e57
--- /dev/null
+++ b/716/CH9/EX9.1.III/9_11_ShortQnA_9_1.sce
@@ -0,0 +1,21 @@
+//Perform DFT of x(n)=(1 1 -2 -2) and sketch magnitude and phase spectrum
+clc;
+clear;
+N=4;
+xn=[1 1 -2 -2];
+for k=0:1:N-1
+ Xk(k+1)=0;
+ for n=0:1:N-1
+ Xk(k+1)=Xk(k+1)+xn(n+1)*exp(-%i*2*%pi*k*n/N);
+ end
+end
+wk=0:1:N-1;
+disp(Xk,'4 point DFT of x(n)=>');
+disp(abs(Xk),'magnitude of 4 point DFT x(n)=>');
+disp(atan(imag(Xk),real(Xk)),'phase of 4 point DFT x(n)=>');
+subplot(1,2,1)
+plot2d3(wk,abs(Xk),2);
+xtitle('Magnitude Spectrum','k','|X(k)|');
+subplot(1,2,2)
+plot2d3(wk,atan(imag(Xk),real(Xk)),2);
+xtitle('Phase Spectrum','k','angle(X(k))'); \ No newline at end of file
diff --git a/716/CH9/EX9.1/Solved_Ex9_1.sce b/716/CH9/EX9.1/Solved_Ex9_1.sce
new file mode 100755
index 000000000..b35e4dbbc
--- /dev/null
+++ b/716/CH9/EX9.1/Solved_Ex9_1.sce
@@ -0,0 +1,41 @@
+//compute 4 point DFT & 8 point DFT and from magnitude and phase spectrums show that DFT coefficients are the samples of Fourier Transform
+clc;
+clear;
+disp('Given signal=> x(n)=1/3.*(n1>=0 & n1<=2)');
+n1=0:1:3;//for four point DFT
+x1=1/3.*(n1>=0 & n1<=2)
+X1=dft(x1,-1);
+disp(X1,'four point DFT of x(n)=>');
+disp(abs(X1),'magnitude of four point DFT x(n)=>');
+disp(atan(imag(X1),real(X1)),'phase of four point DFT x(n)=>');
+subplot(1,2,1)
+plot2d3(n1,abs(X1),2);
+xtitle('Magnitude Spectrum for 4 point DFT','k','|X(k)|');
+subplot(1,2,2)
+plot2d3(n1,atan(imag(X1),real(X1)),2);
+xtitle('Phase Spectrum for 4 point DFT','k','angle(X(k))');
+
+n2=0:1:7;//for Eight point DFT
+x2=1/3.*(n2>=0 & n2<=2)
+X2=dft(x2,-1);
+disp(X2,'eight point DFT of x(n)=>');
+disp(abs(X2),'magnitude of eight point DFT x(n)=>');
+disp(atan(imag(X2),real(X2)),'phase of four point DFT x(n)=>');
+xset('window',1);
+subplot(1,2,1)
+plot2d3(n2,abs(X2),2);
+xtitle('Magnitude Spectrum for 8 point DFT','k','|X(k)|');
+subplot(1,2,2)
+plot2d3(n2,atan(imag(X2),real(X2)),2);
+xtitle('Phase Spectrum for 8 point DFT','k','angle(X(k))');
+
+n3=0:1:15;//for four point DFT
+x3=1/3.*(n3>=0 & n3<=2)
+X3=dft(x3,-1);
+xset('window',2);
+subplot(1,2,1)
+plot2d3(n3,abs(X3),2);
+xtitle('Magnitude Spectrum for 8 point DFT','k','|X(k)|');
+subplot(1,2,2)
+plot2d3(n3,atan(imag(X3),real(X3)),2);
+xtitle('Phase Spectrum for 16 point DFT','k','angle(X(k))'); \ No newline at end of file
diff --git a/716/CH9/EX9.2.III/9_11_ShortQnA_9_2.sce b/716/CH9/EX9.2.III/9_11_ShortQnA_9_2.sce
new file mode 100755
index 000000000..3b66e77ae
--- /dev/null
+++ b/716/CH9/EX9.2.III/9_11_ShortQnA_9_2.sce
@@ -0,0 +1,21 @@
+//Perform 4 point DFT of x(n)=(1 1 0 0) and sketch magnitude and phase spectrum
+clc;
+clear;
+N=4;
+xn=[1 1 0 0];
+for k=0:1:N-1
+ Xk(k+1)=0;
+ for n=0:1:N-1
+ Xk(k+1)=Xk(k+1)+xn(n+1)*exp(-%i*2*%pi*k*n/N);
+ end
+end
+wk=0:1:N-1;
+disp(Xk,'4 point DFT of x(n)=>');
+disp(abs(Xk),'magnitude of 4 point DFT x(n)=>');
+disp(atan(imag(Xk),real(Xk)),'phase of 4 point DFT x(n)=>');
+subplot(1,2,1)
+plot2d3(wk,abs(Xk),2);
+xtitle('Magnitude Spectrum','k','|X(k)|');
+subplot(1,2,2)
+plot2d3(wk,atan(imag(Xk),real(Xk)),2);
+xtitle('Phase Spectrum','k','angle(X(k))'); \ No newline at end of file
diff --git a/716/CH9/EX9.2.V/9_13_ExerciseV9_2.sce b/716/CH9/EX9.2.V/9_13_ExerciseV9_2.sce
new file mode 100755
index 000000000..61584df58
--- /dev/null
+++ b/716/CH9/EX9.2.V/9_13_ExerciseV9_2.sce
@@ -0,0 +1,21 @@
+//Perform 4 point DFT of x(n)=(0 -1 2 1) and sketch magnitude and phase spectrum
+clc;
+clear;
+N=4;
+xn=[0 -1 2 1];
+for k=0:1:N-1
+ Xk(k+1)=0;
+ for n=0:1:N-1
+ Xk(k+1)=Xk(k+1)+xn(n+1)*exp(-%i*2*%pi*k*n/N);
+ end
+end
+wk=0:1:N-1;
+disp(Xk,'4 point DFT of x(n)=>');
+disp(abs(Xk),'magnitude of 4 point DFT x(n)=>');
+disp(atan(imag(Xk),real(Xk)),'phase of 4 point DFT x(n)=>');
+subplot(1,2,1)
+plot2d3(wk,abs(Xk),2);
+xtitle('Magnitude Spectrum','k','|X(k)|');
+subplot(1,2,2)
+plot2d3(wk,atan(imag(Xk),real(Xk)),2);
+xtitle('Phase Spectrum','k','angle(X(k))'); \ No newline at end of file
diff --git a/716/CH9/EX9.2.m/MatLab_Prog9_2.sce b/716/CH9/EX9.2.m/MatLab_Prog9_2.sce
new file mode 100755
index 000000000..93321c76e
--- /dev/null
+++ b/716/CH9/EX9.2.m/MatLab_Prog9_2.sce
@@ -0,0 +1,24 @@
+//Perform 16 point DFT of x(n)=(1/3 1/3 1/3) and sketch magnitude and phase spectrum
+clc;
+clear;
+N=16;
+xn=zeros(1,16);
+xn(1)=1/3;
+xn(2)=1/3;
+xn(3)=1/3;
+for k=0:1:N-1
+ Xk(k+1)=0;
+ for n=0:1:N-1
+ Xk(k+1)=Xk(k+1)+xn(n+1)*exp(-%i*2*%pi*k*n/N);
+ end
+end
+wk=0:1:N-1;
+disp(Xk,'16 point DFT of x(n)=>');
+disp(abs(Xk),'magnitude of 16 point DFT x(n)=>');
+disp(atan(imag(Xk),real(Xk)),'phase of 16 point DFT x(n)=>');
+subplot(1,2,1)
+plot2d3(wk,abs(Xk),2);
+xtitle('Magnitude Spectrum','k','|X(k)|');
+subplot(1,2,2)
+plot2d3(wk,atan(imag(Xk),real(Xk)),2);
+xtitle('Phase Spectrum','k','angle(X(k))'); \ No newline at end of file
diff --git a/716/CH9/EX9.2/Solved_Ex9_2.sce b/716/CH9/EX9.2/Solved_Ex9_2.sce
new file mode 100755
index 000000000..588f06e7c
--- /dev/null
+++ b/716/CH9/EX9.2/Solved_Ex9_2.sce
@@ -0,0 +1,16 @@
+//compute 4 point DFT of signal x(n)={0,1,2,3}
+clc;
+clear;
+n=0:1:3;//for four point DFT
+x=[0 1 2 3];
+disp(x,'Given signal=> x(n)=');
+X=dft(x,-1);
+disp(X,'four point DFT of x(n)=>');
+disp(abs(X),'magnitude of four point DFT x(n)=>');
+disp(atan(imag(X),real(X)),'phase of four point DFT x(n)=>');
+subplot(1,2,1)
+plot2d3(n,abs(X),2);
+xtitle('Magnitude Spectrum','k','|X(k)|');
+subplot(1,2,2)
+plot2d3(n,atan(imag(X),real(X)),2);
+xtitle('Phase Spectrum','k','angle(X(k))'); \ No newline at end of file
diff --git a/716/CH9/EX9.3.V/9_13_ExerciseV9_3.sce b/716/CH9/EX9.3.V/9_13_ExerciseV9_3.sce
new file mode 100755
index 000000000..492d4b7ee
--- /dev/null
+++ b/716/CH9/EX9.3.V/9_13_ExerciseV9_3.sce
@@ -0,0 +1,21 @@
+//Perform DFT of x(n)=(1 1 1 2 2) and sketch magnitude and phase spectrum
+clc;
+clear;
+N=5;
+xn=[1 1 1 2 2];
+for k=0:1:N-1
+ Xk(k+1)=0;
+ for n=0:1:N-1
+ Xk(k+1)=Xk(k+1)+xn(n+1)*exp(-%i*2*%pi*k*n/N);
+ end
+end
+wk=0:1:N-1;
+disp(Xk,'4 point DFT of x(n)=>');
+disp(abs(Xk),'magnitude of 4 point DFT x(n)=>');
+disp(atan(imag(Xk),real(Xk)),'phase of 4 point DFT x(n)=>');
+subplot(1,2,1)
+plot2d3(wk,abs(Xk),2);
+xtitle('Magnitude Spectrum','k','|X(k)|');
+subplot(1,2,2)
+plot2d3(wk,atan(imag(Xk),real(Xk)),2);
+xtitle('Phase Spectrum','k','angle(X(k))'); \ No newline at end of file
diff --git a/716/CH9/EX9.3/Solved_Ex9_3.sce b/716/CH9/EX9.3/Solved_Ex9_3.sce
new file mode 100755
index 000000000..9a9e9de57
--- /dev/null
+++ b/716/CH9/EX9.3/Solved_Ex9_3.sce
@@ -0,0 +1,21 @@
+//compute circular convolution of x1(n)={2 1 2 1} & x2(n)={1 2 3 4}
+clc;
+clear;
+n=0:1:3;//for four point DFT
+x1=[1 2 3 4];
+disp(x1,'Given signal=> x1(n)=');
+X1=dft(x1,-1);
+disp(X1,'four point DFT of x(n)=>');
+disp(abs(X1),'magnitude of four point DFT x(n)=>');
+disp(atan(imag(X1),real(X1)),'phase of four point DFT x(n)=>');
+
+x2=[2 1 2 1];
+disp(x2,'Given signal=> x1(n)=');
+X2=dft(x2,-1);
+disp(X2,'four point DFT of x(n)=>');
+disp(abs(X2),'magnitude of four point DFT x(n)=>');
+disp(atan(imag(X2),real(X2)),'phase of four point DFT x(n)=>');
+
+X3=X1.*X2;
+x3=dft(X3,1);
+disp(x3,'by circular convolution x3(n)=>'); \ No newline at end of file
diff --git a/716/CH9/EX9.4.V/9_13_ExerciseV9_4.sce b/716/CH9/EX9.4.V/9_13_ExerciseV9_4.sce
new file mode 100755
index 000000000..b03bac3dd
--- /dev/null
+++ b/716/CH9/EX9.4.V/9_13_ExerciseV9_4.sce
@@ -0,0 +1,21 @@
+//compute circular convolution of x1(n)={-1 2 -2 1} & x2(n)={1 -2 -1 2}
+clc;
+clear;
+n=0:1:3;//for four point DFT
+x1=[-1 2 -2 1];
+disp(x1,'Given signal=> x1(n)=');
+X1=dft(x1,-1);
+disp(X1,'four point DFT of x(n)=>');
+disp(abs(X1),'magnitude of four point DFT x(n)=>');
+disp(atan(imag(X1),real(X1)),'phase of four point DFT x(n)=>');
+
+x2=[1 -2 -1 2];
+disp(x2,'Given signal=> x1(n)=');
+X2=dft(x2,-1);
+disp(X2,'four point DFT of x(n)=>');
+disp(abs(X2),'magnitude of four point DFT x(n)=>');
+disp(atan(imag(X2),real(X2)),'phase of four point DFT x(n)=>');
+
+X3=X1.*X2;
+x3=dft(X3,1);
+disp(x3,'by circular convolution x3(n)=>'); \ No newline at end of file
diff --git a/716/CH9/EX9.5.m/MatLab_Prog9_5.sce b/716/CH9/EX9.5.m/MatLab_Prog9_5.sce
new file mode 100755
index 000000000..2c20ecc8d
--- /dev/null
+++ b/716/CH9/EX9.5.m/MatLab_Prog9_5.sce
@@ -0,0 +1,21 @@
+//Perform 4 point DFT of x(n)=(1 1 2 3) using FFT and sketch magnitude and phase spectrum
+clc;
+clear;
+N=4;
+xn=[1 1 2 3]
+Xk=fft(xn);
+wk=0:1:N-1;
+disp(Xk,'16 point DFT of x(n)=>');
+disp(abs(Xk),'magnitude of 16 point DFT x(n)=>');
+disp(atan(imag(Xk),real(Xk)),'phase of 16 point DFT x(n)=>');
+plot2d3(wk,xn,2);
+isoview(0,5,0,3);
+xset('window',1);
+subplot(1,2,1)
+plot2d3(wk,abs(Xk),2);
+isoview(0,5,0,5);
+xtitle('Magnitude Spectrum','k','|X(k)|');
+subplot(1,2,2)
+plot2d3(wk,atan(imag(Xk),real(Xk)),2);
+isoview(0,5,-5,5);
+xtitle('Phase Spectrum','k','angle(X(k))'); \ No newline at end of file
diff --git a/716/CH9/EX9.5/Solved_Ex9_5.sce b/716/CH9/EX9.5/Solved_Ex9_5.sce
new file mode 100755
index 000000000..6b6df0969
--- /dev/null
+++ b/716/CH9/EX9.5/Solved_Ex9_5.sce
@@ -0,0 +1,16 @@
+//compute 8 point DFT of x(n)={2 2 2 2 1 1 1 1}
+clc;
+clear;
+n=0:1:7;//for 8 point DFT
+x=[2 2 2 2 1 1 1 1];
+disp(x,'Given signal=> x(n)=');
+X=fft(x);
+disp(X,'8 point FFT of x(n)=>');
+disp(abs(X),'magnitude of 8 point FFT x(n)=>');
+disp(atan(imag(X),real(X)),'phase of 8 point FFT x(n)=>');
+subplot(1,2,1)
+plot2d3(n,abs(X),2);
+xtitle('Magnitude Spectrum','k','|X(k)|');
+subplot(1,2,2)
+plot2d3(n,atan(imag(X),real(X)),2);
+xtitle('Phase Spectrum','k','angle(X(k))');
diff --git a/716/CH9/EX9.6/Solved_Ex9_6.sce b/716/CH9/EX9.6/Solved_Ex9_6.sce
new file mode 100755
index 000000000..bbf6ef324
--- /dev/null
+++ b/716/CH9/EX9.6/Solved_Ex9_6.sce
@@ -0,0 +1,25 @@
+//Determine the Response of LTI system if input x(n)={1 1 1} and impulse Response h(n)={-1 -1}
+clc;
+clear;
+x=[1 1 1];
+disp(x,'Input signal=> x(n)=');
+h=[-1 -1];
+disp(h,'Impulse Response=> h(n)=');
+k=length(x)+length(h)-1;
+for n=length(x)+1:1:k
+ x(n)=0;//appending 0s
+end
+for n=length(h)+1:1:k
+ h(n)=0;//appending 0s
+end
+n=0:1:k;
+
+X=fft(x);
+disp(X,'4 point FFT of x(n)=>');
+
+H=fft(h);
+disp(X,'4 point FFT of h(n)=>');
+
+Y=X.*H;
+y=ifft(Y);
+disp(y,'Response to input,x(n)=> y(n)='); \ No newline at end of file
diff --git a/716/CH9/EX9.7/Solved_Ex9_7.sce b/716/CH9/EX9.7/Solved_Ex9_7.sce
new file mode 100755
index 000000000..40180ea48
--- /dev/null
+++ b/716/CH9/EX9.7/Solved_Ex9_7.sce
@@ -0,0 +1,25 @@
+//Determine the Response of LTI system if input x(n)={-1 1 2 1 -1} and impulse Response h(n)={-1 1 -1 1}
+clc;
+clear;
+x=[-1 1 2 1 -1];
+disp(x,'Input signal=> x(n)=');
+h=[-1 1 -1 1];
+disp(h,'Impulse Response=> h(n)=');
+k=length(x)+length(h)-1;
+for n=length(x)+1:1:k
+ x(n)=0;//appending 0s
+end
+for n=length(h)+1:1:k
+ h(n)=0;//appending 0s
+end
+n=0:1:k;
+
+X=fft(x);
+disp(X,'4 point FFT of x(n)=>');
+
+H=fft(h);
+disp(X,'4 point FFT of h(n)=>');
+
+Y=X.*H;
+y=ifft(Y);
+disp(y,'Response to input,x(n)=> y(n)='); \ No newline at end of file