diff options
Diffstat (limited to '40')
-rwxr-xr-x | 40/CH10/EX10.5a/Exa_10_5a.sce | 62 | ||||
-rwxr-xr-x | 40/CH10/EX10.5b/Exa_10_5b.sce | 62 | ||||
-rwxr-xr-x | 40/CH5/EX5.5/Exa_5_5.sce | 12 | ||||
-rwxr-xr-x | 40/CH8/EX8.1/Exa_8_1.sce | 10 | ||||
-rwxr-xr-x | 40/CH8/EX8.10/Exa_8_10.sce | 16 | ||||
-rwxr-xr-x | 40/CH8/EX8.11/Exa_8_11.sce | 52 | ||||
-rwxr-xr-x | 40/CH8/EX8.16/Exa_8_16.sce | 22 | ||||
-rwxr-xr-x | 40/CH8/EX8.2/Exa_8_2.sce | 10 | ||||
-rwxr-xr-x | 40/CH8/EX8.24/Exa_8_24.sce | 48 | ||||
-rwxr-xr-x | 40/CH8/EX8.4/Exa_8_4.sce | 42 | ||||
-rwxr-xr-x | 40/CH8/EX8.5a/Exa_8_5a.sce | 82 | ||||
-rwxr-xr-x | 40/CH8/EX8.5b/Exa_8_5b.sce | 84 | ||||
-rwxr-xr-x | 40/CH8/EX8.5c/Exa_8_5c.sce | 12 | ||||
-rwxr-xr-x | 40/CH8/EX8.6/Exa_8_6.sce | 38 | ||||
-rwxr-xr-x | 40/CH8/EX8.7/Exa_8_7.sce | 14 | ||||
-rwxr-xr-x | 40/CH8/EX8.8/Exa_8_8.sce | 18 | ||||
-rwxr-xr-x | 40/CH8/EX8.9a/Exa_8_9a.sce | 30 | ||||
-rwxr-xr-x | 40/CH8/EX8.9b/Exa_8_9b.sce | 30 | ||||
-rwxr-xr-x | 40/CH8/EX8.9c/Exa_8_9c.sce | 30 | ||||
-rwxr-xr-x | 40/CH8/EX8.9d/Exa_8_9d.sce | 28 |
20 files changed, 351 insertions, 351 deletions
diff --git a/40/CH10/EX10.5a/Exa_10_5a.sce b/40/CH10/EX10.5a/Exa_10_5a.sce index 42d0cbf29..9f1e98c69 100755 --- a/40/CH10/EX10.5a/Exa_10_5a.sce +++ b/40/CH10/EX10.5a/Exa_10_5a.sce @@ -1,32 +1,32 @@ -//Fir low pass filter design by frequency sampling
-z=%z;
-N=10;
-magHk=[1 1 1 0 0 0 0 0 1 1];
-k=[0:7 -1 -2];
-fik=-%pi*k'*(N-1)/N;
-for i=1:length(fik)
- H1k(i)=magHk(i)*exp(%i*fik(i));
-end
-H1n=(dft(H1k,1));
-H2k=H1k;
-H2k(3)=0.5*%e^(-%i*1.8*%pi);
-H2k(9)=0.5*%e^(%i*1.8*%pi);
-H2n=(dft(H2k,1));
-H1Z=0;H2Z=0;
-for i=1:length(H1n)
- H1Z=H1Z+H1n(i)*z^(-i);
-end
-for i=1:length(H2n)
- H2Z=H2Z+H2n(i)*z^(-i);
-end
-F=0:0.01:1;
-F1=0:0.1:0.9;
-H1F=abs(horner(H1Z,exp(%i*2*%pi*F')));
-H2F=abs(horner(H2Z,exp(%i*2*%pi*F')));
-a=gca();
-plot2d(F1,magHk);
-plot2d(F,H2F);
-plot2d(F,H1F);
-xlabel('Digital Frequency F');
-ylabel('magnitude');
+//For low pass filter design by frequency sampling +z=%z; +N=10; +magHk=[1 1 1 0 0 0 0 0 1 1]; +k=[0:7 -1 -2]; +fik=-%pi*k'*(N-1)/N; +for i=1:length(fik) + H1k(i)=magHk(i)*exp(%i*fik(i)); +end +H1n=(fft(H1k,1)); +H2k=H1k; +H2k(3)=0.5*%e^(-%i*1.8*%pi); +H2k(9)=0.5*%e^(%i*1.8*%pi); +H2n=(fft(H2k,1)); +H1Z=0;H2Z=0; +for i=1:length(H1n) + H1Z=H1Z+H1n(i)*z^(-i); +end +for i=1:length(H2n) + H2Z=H2Z+H2n(i)*z^(-i); +end +F=0:0.01:1; +F1=0:0.1:0.9; +H1F=abs(horner(H1Z,exp(%i*2*%pi*F'))); +H2F=abs(horner(H2Z,exp(%i*2*%pi*F'))); +a=gca(); +plot2d(F1,magHk); +plot2d(F,H2F); +plot2d(F,H1F); +xlabel('Digital Frequency F'); +ylabel('magnitude'); xtitle('Low pass filter using frequency sampling');
\ No newline at end of file diff --git a/40/CH10/EX10.5b/Exa_10_5b.sce b/40/CH10/EX10.5b/Exa_10_5b.sce index 7a3f04ee9..b98473816 100755 --- a/40/CH10/EX10.5b/Exa_10_5b.sce +++ b/40/CH10/EX10.5b/Exa_10_5b.sce @@ -1,32 +1,32 @@ -//Fir high pass filter design by frequency sampling
-z=%z;
-N=10;
-magHk=[0 0 0 1 1 1 1 1 0 0];
-k=[0:5 -4:-1:-1];
-fik=(-%pi*k'*(N-1)/N)+(0.5*%pi);
-for i=1:length(fik)
- H1k(i)=magHk(i)*exp(%i*fik(i));
-end
-H1n=(dft(H1k,1));
-H2k=H1k;
-H2k(3)=0.5*%e^(-%i*1.3*%pi);
-H2k(9)=0.5*%e^(%i*1.3*%pi);
-H2n=(dft(H2k,1));
-H1Z=0;H2Z=0;
-for i=1:length(H1n)
- H1Z=H1Z+H1n(i)*z^(-i);
-end
-for i=1:length(H2n)
- H2Z=H2Z+H2n(i)*z^(-i);
-end
-F=0:0.01:1;
-F1=0:0.1:0.9;
-H1F=abs(horner(H1Z,exp(%i*2*%pi*F')));
-H2F=abs(horner(H2Z,exp(%i*2*%pi*F')));
-a=gca();
-plot2d(F1,magHk);
-plot2d(F,H2F);
-plot2d(F,H1F);
-xlabel('Digital Frequency F');
-ylabel('magnitude');
+//For high pass filter design by frequency sampling +z=%z; +N=10; +magHk=[0 0 0 1 1 1 1 1 0 0]; +k=[0:5 -4:-1:-1]; +fik=(-%pi*k'*(N-1)/N)+(0.5*%pi); +for i=1:length(fik) + H1k(i)=magHk(i)*exp(%i*fik(i)); +end +H1n=(fft(H1k,1)); +H2k=H1k; +H2k(3)=0.5*%e^(-%i*1.3*%pi); +H2k(9)=0.5*%e^(%i*1.3*%pi); +H2n=(fft(H2k,1)); +H1Z=0;H2Z=0; +for i=1:length(H1n) + H1Z=H1Z+H1n(i)*z^(-i); +end +for i=1:length(H2n) + H2Z=H2Z+H2n(i)*z^(-i); +end +F=0:0.01:1; +F1=0:0.1:0.9; +H1F=abs(horner(H1Z,exp(%i*2*%pi*F'))); +H2F=abs(horner(H2Z,exp(%i*2*%pi*F'))); +a=gca(); +plot2d(F1,magHk); +plot2d(F,H2F); +plot2d(F,H1F); +xlabel('Digital Frequency F'); +ylabel('magnitude'); xtitle('Low pass filter using frequency sampling');
\ No newline at end of file diff --git a/40/CH5/EX5.5/Exa_5_5.sce b/40/CH5/EX5.5/Exa_5_5.sce index 0ad017d37..0b1ba221e 100755 --- a/40/CH5/EX5.5/Exa_5_5.sce +++ b/40/CH5/EX5.5/Exa_5_5.sce @@ -1,7 +1,7 @@ -x=[1 0 2 0 3];//one period of signal
-n=0:4;
-k=0:4;
-x1=x*exp(%i*n'*2*k*%pi/4)
-DTFTx=abs(x1)
-DFT=dft(x,-1)
+x=[1 0 2 0 3];//one period of signal +n=0:4; +k=0:4; +x1=x*exp(%i*n'*2*k*%pi/4) +DTFTx=abs(x1) +DFT=fft(x,-1) DFS=DFT/5
\ No newline at end of file diff --git a/40/CH8/EX8.1/Exa_8_1.sce b/40/CH8/EX8.1/Exa_8_1.sce index 000b8b907..ab20fffa1 100755 --- a/40/CH8/EX8.1/Exa_8_1.sce +++ b/40/CH8/EX8.1/Exa_8_1.sce @@ -1,6 +1,6 @@ -//DFT from defining relation
-//N-point DFT
-x=[1 2 1 0];
-XDFT=dft(x,-1);
-disp(XDFT,'The DFT of x[n] is');
+//DFT from defining relation +//N-point DFT +x=[1 2 1 0]; +XDFT=fft(x,-1); +disp(XDFT,'The DFT of x[n] is'); //DFT of periodic signal x with period N=4
\ No newline at end of file diff --git a/40/CH8/EX8.10/Exa_8_10.sce b/40/CH8/EX8.10/Exa_8_10.sce index d9676ae26..73e93d035 100755 --- a/40/CH8/EX8.10/Exa_8_10.sce +++ b/40/CH8/EX8.10/Exa_8_10.sce @@ -1,9 +1,9 @@ -//DFS of sampled periodic signals
-xn=[0 ones(2:16) 0 -ones(18:32)];
-XDFS=0.032*dft(xn,-1);
-for i=1:length(XDFS)
- if (abs(XDFS(i))<0.000001) then
- XDFS(i)=0;
- end
-end
+//DFS of sampled periodic signals +xn=[0 ones(2:16) 0 -ones(18:32)]; +XDFS=0.032*fft(xn,-1); +for i=1:length(XDFS) + if (abs(XDFS(i))<0.000001) then + XDFS(i)=0; + end +end disp(XDFS,'The DFS of x[n] is');
\ No newline at end of file diff --git a/40/CH8/EX8.11/Exa_8_11.sce b/40/CH8/EX8.11/Exa_8_11.sce index 5b086398e..77698dfea 100755 --- a/40/CH8/EX8.11/Exa_8_11.sce +++ b/40/CH8/EX8.11/Exa_8_11.sce @@ -1,27 +1,27 @@ -//Effects of leakage
-n1=0:0.005:0.1;
-n2=0:0.005:0.125;
-n3=0:0.005:1.125;
-xt1=(2*cos(20*%pi*n1')+5*cos(100*%pi*n1'));
-xt2=(2*cos(20*%pi*n2')+5*cos(100*%pi*n2'));
-xt3=(2*cos(20*%pi*n3')+5*cos(100*%pi*n3'));
-XDFS1=abs(dft(xt1,-1))/20;
-XDFS2=abs(dft(xt2,-1))/25;
-XDFS3=abs(dft(xt3,-1))/225;
-f1=0:5:100;
-f2=0:4:100;
-f3=0:100/225:100;
-a=gca();
-a.x_location="origin";
-plot2d3('gnn',f1,XDFS1);
-xlabel('analog frequency');
-ylabel('Magnitude');
-xset('window',1);
-subplot(211);
-plot2d3('gnn',f2,XDFS2);
-xlabel('analog frequency');
-ylabel('Magnitude');
-subplot(212);
-plot2d3('gnn',f3,XDFS3);
-xlabel('analog frequency');
+//Effects of leakage +n1=0:0.005:0.1; +n2=0:0.005:0.125; +n3=0:0.005:1.125; +xt1=(2*cos(20*%pi*n1')+5*cos(100*%pi*n1')); +xt2=(2*cos(20*%pi*n2')+5*cos(100*%pi*n2')); +xt3=(2*cos(20*%pi*n3')+5*cos(100*%pi*n3')); +XDFS1=abs(fft(xt1,-1))/20; +XDFS2=abs(fft(xt2,-1))/25; +XDFS3=abs(fft(xt3,-1))/225; +f1=0:5:100; +f2=0:4:100; +f3=0:100/225:100; +a=gca(); +a.x_location="origin"; +plot2d3('gnn',f1,XDFS1); +xlabel('analog frequency'); +ylabel('Magnitude'); +xset('window',1); +subplot(211); +plot2d3('gnn',f2,XDFS2); +xlabel('analog frequency'); +ylabel('Magnitude'); +subplot(212); +plot2d3('gnn',f3,XDFS3); +xlabel('analog frequency'); ylabel('Magnitude');
\ No newline at end of file diff --git a/40/CH8/EX8.16/Exa_8_16.sce b/40/CH8/EX8.16/Exa_8_16.sce index 4bd0eb54e..e26b99b6f 100755 --- a/40/CH8/EX8.16/Exa_8_16.sce +++ b/40/CH8/EX8.16/Exa_8_16.sce @@ -1,12 +1,12 @@ -//signal interpolation using FFT
-xn=[0 1 0 -1];
-XDFT=dft(xn,-1)
-ZT=[0 -2*%i 0 zeros(1:27) 0 2*%i];
-xn1=dft(ZT,1);
-t=0:1/length(xn1):1-(1/length(xn1));
-a=gca();
-a.x_location="origin";
-plot2d(t,xn1);
-xlabel('time t');
-ylabel('Amplitude');
+//signal interpolation using FFT +xn=[0 1 0 -1]; +XDFT=fft(xn,-1) +ZT=[0 -2*%i 0 zeros(1:27) 0 2*%i]; +xn1=fft(ZT,1); +t=0:1/length(xn1):1-(1/length(xn1)); +a=gca(); +a.x_location="origin"; +plot2d(t,xn1); +xlabel('time t'); +ylabel('Amplitude'); xtitle('Interpolated Sinusoid:4 samples over one period');
\ No newline at end of file diff --git a/40/CH8/EX8.2/Exa_8_2.sce b/40/CH8/EX8.2/Exa_8_2.sce index 39450d7f1..716bed88b 100755 --- a/40/CH8/EX8.2/Exa_8_2.sce +++ b/40/CH8/EX8.2/Exa_8_2.sce @@ -1,6 +1,6 @@ -//The DTFT and conjugate symmetry
-//8-point DFT
-x=[1 1 0 0 0 0 0 0];
-XDFT=dft(x,-1);
-disp(XDFT,'The DFT of x is');
+//The DTFT and conjugate symmetry +//8-point DFT +x=[1 1 0 0 0 0 0 0]; +XDFT=fft(x,-1); +disp(XDFT,'The DFT of x is'); disp('from conjugate symmetry we see XDFT[k]=XDFT[8-k]');
\ No newline at end of file diff --git a/40/CH8/EX8.24/Exa_8_24.sce b/40/CH8/EX8.24/Exa_8_24.sce index 5ad54e146..4cf5fd699 100755 --- a/40/CH8/EX8.24/Exa_8_24.sce +++ b/40/CH8/EX8.24/Exa_8_24.sce @@ -1,24 +1,24 @@ -//The importance of Periodic extension
-//(a)For M=3
-x=[1 2 1];
-XDFT=dft(x,-1)
-w=exp(-%i*2*%pi/3);
-for i=1:3
- for j=1:3
- WN(i,j)=w^((i-1)*(j-1));
- end
-end
-WI=WN';
-xn=1/3*WI*XDFT
-//The result is periodic with M=3 & 1 period equals x[n]
-//(b)For M=4
-y=[1 2 1 0];
-YDFT=dft(y,-1)
-w=exp(-%i*%pi/2);
-for i=1:4
- for j=1:4
- WN(i,j)=w^((i-1)*(j-1));
- end
-end
-WI=WN';
-yn=1/4*WI*YDFT
+//The importance of Periodic extension +//(a)For M=3 +x=[1 2 1]; +XDFT=fft(x,-1)' +w=exp(-%i*2*%pi/3); +for i=1:3 + for j=1:3 + WN(i,j)=w^((i-1)*(j-1)); + end +end +WI=WN'; +xn=1/3*WI*XDFT +//The result is periodic with M=3 & 1 period equals x[n] +//(b)For M=4 +y=[1 2 1 0]; +YDFT=fft(y,-1)' +w=exp(-%i*%pi/2); +for i=1:4 + for j=1:4 + WN(i,j)=w^((i-1)*(j-1)); + end +end +WI=WN'; +yn=1/4*WI*YDFT
\ No newline at end of file diff --git a/40/CH8/EX8.4/Exa_8_4.sce b/40/CH8/EX8.4/Exa_8_4.sce index 847b1bfa2..64026fb34 100755 --- a/40/CH8/EX8.4/Exa_8_4.sce +++ b/40/CH8/EX8.4/Exa_8_4.sce @@ -1,21 +1,21 @@ -x=[1 2 1 0];
-XDFT=dft(x,-1)
-//(a)time shift property
-y=x;
-for i=1:2
- a=y(1);
- for j=1:length(y)-1
- y(j)=y(j+1);
- end
- y(length(y))=a;
-end
-YDFT=dft(y,-1)
-disp(YDFT,'By Time-Shift property DFT of x[n-2] is');
-//(b)flipping property
-g=[x(1) x(length(x):-1:2)]
-GDFT=dft(g,-1)
-disp(GDFT,'By Time reversal property DFT of x[-n] is');
-//(c)conjugation property
-p=XDFT;
-PDFT=[p(1);p(4:-1:2)];
-disp(YDFT,'BY conjugation property DFT of x*[n] is');
+x=[1 2 1 0]; +XDFT=fft(x,-1) +//(a)time shift property +y=x; +for i=1:2 + a=y(1); + for j=1:length(y)-1 + y(j)=y(j+1); + end + y(length(y))=a; +end +YDFT=fft(y,-1) +disp(YDFT,'By Time-Shift property DFT of x[n-2] is'); +//(b)flipping property +g=[x(1) x(length(x):-1:2)] +GDFT=fft(g,-1) +disp(GDFT,'By Time reversal property DFT of x[-n] is'); +//(c)conjugation property +p=XDFT; +PDFT=[p(1) p(4:-1:2)]; +disp(YDFT,'BY conjugation property DFT of x*[n] is');
\ No newline at end of file diff --git a/40/CH8/EX8.5a/Exa_8_5a.sce b/40/CH8/EX8.5a/Exa_8_5a.sce index 63e5aa5a4..6e7a694df 100755 --- a/40/CH8/EX8.5a/Exa_8_5a.sce +++ b/40/CH8/EX8.5a/Exa_8_5a.sce @@ -1,42 +1,42 @@ -//properties of DFT
-//a1)product
-xn=[1 2 1 0];
-XDFT=dft(xn,-1)
-hn=xn.*xn
-HDFT=dft(hn,-1)
-HDFT1=1/4*(convol(XDFT,XDFT))
-HDFT1=[HDFT1,zeros(8:12)];
-HDFT2=[HDFT1(1:4);HDFT1(5:8);HDFT1(9:12)];
-HDFT3=[0 0 0 0];
-for i=1:4
- for j=1:3
- HDFT3(i)=HDFT3(i)+HDFT2(j,i);
- end
-end
-disp(HDFT3,'DFT of x[n]^2 is');
-//a2)periodic convolution
-vn=convol(xn,xn);
-vn=[vn,zeros(8:12)];
-vn=[vn(1:4);vn(5:8);vn(9:12)];
-vn1=[0 0 0 0];
-for i=1:4
- for j=1:3
- vn1(i)=vn1(i)+vn(j,i);
- end
-end
-VDFT=dft(vn1,-1);
-VDFT1=XDFT.*XDFT;
-disp(VDFT1,'DFT of x[n]*x[n] is');
-//a3)signal energy(parcewell's theorem)
-xn2=xn^2;
-E=0;
-for i=1:length(xn2)
- E=E+abs(xn2(i));
-end
-XDFT2=XDFT^2
-E1=0;
-for i=1:length(XDFT2)
- E1=E1+abs(XDFT2(i));
-end
-E,(1/4)*E1;
+//properties of DFT +//a1)product +xn=[1 2 1 0]; +XDFT=fft(xn,-1) +hn=xn.*xn +HDFT=fft(hn,-1) +HDFT1=1/4*(convol(XDFT,XDFT)) +HDFT1=[HDFT1,zeros(8:12)]; +HDFT2=[HDFT1(1:4);HDFT1(5:8);HDFT1(9:12)]; +HDFT3=[0 0 0 0]; +for i=1:4 + for j=1:3 + HDFT3(i)=HDFT3(i)+HDFT2(j,i); + end +end +disp(HDFT3,'DFT of x[n]^2 is'); +//a2)periodic convolution +vn=convol(xn,xn); +vn=[vn,zeros(8:12)]; +vn=[vn(1:4);vn(5:8);vn(9:12)]; +vn1=[0 0 0 0]; +for i=1:4 + for j=1:3 + vn1(i)=vn1(i)+vn(j,i); + end +end +VDFT=fft(vn1,-1); +VDFT1=XDFT.*XDFT; +disp(VDFT1,'DFT of x[n]*x[n] is'); +//a3)signal energy(parcewell's theorem) +xn2=xn.^2; +E=0; +for i=1:length(xn2) + E=E+abs(xn2(i)); +end +XDFT2=XDFT.^2 +E1=0; +for i=1:length(XDFT2) + E1=E1+abs(XDFT2(i)); +end +E,(1/4)*E1; disp(1/4*E1,'The energy of the signal is');
\ No newline at end of file diff --git a/40/CH8/EX8.5b/Exa_8_5b.sce b/40/CH8/EX8.5b/Exa_8_5b.sce index 05c7e80c0..0c97e81c7 100755 --- a/40/CH8/EX8.5b/Exa_8_5b.sce +++ b/40/CH8/EX8.5b/Exa_8_5b.sce @@ -1,42 +1,42 @@ -//b1)modulation
-XDFT=[4 -2*%i 0 2*%i];
-xn=dft(XDFT,1)
-for i=1:length(xn)
- zn(i)=xn(i)*%e^((%i*%pi*(i-1))/2);
-end
-disp(zn,'The IDFT of XDFT[k-1] is');
-ZDFT=[2*%i 4 -2*%i 0];
-zn1=dft(ZDFT,1)
-//b2)periodic convolution
-HDFT=(convol(XDFT,XDFT))
-HDFT=[HDFT,zeros(8:12)];
-HDFT=[HDFT(1:4);HDFT(5:8);HDFT(9:12)];
-HDFT1=[0 0 0 0];
-for i=1:4
- for j=1:3
- HDFT1(i)=HDFT1(i)+HDFT(j,i);
- end
-end
-HDFT1;
-hn=dft(HDFT1,1)
-hn1=4*(xn.*xn);
-disp(hn1,'The IDFT of XDFT*XDFT is');
-//b3)product
-WDFT=XDFT.*XDFT;
-wn=dft(WDFT,1)
-wn1=convol(xn,xn);
-wn1=[wn1,zeros(8:12)];
-wn1=[wn1(1:4);wn1(5:8);wn1(9:12)];
-WN=[0 0 0 0];
-for i=1:4
- for j=1:3
- WN(i)=WN(i)+wn1(j,i);
- end
-end
-disp(WN,'The IDFT of XDFT.XDFT is');
-//b4)Central ordinates and signal Energy
-E=0;
-for i=1:length(xn)
- E=E+abs(xn(i)^2);
-end
-disp(E,'the signal energy is');
\ No newline at end of file +//b1)modulation +XDFT=[4 -2*%i 0 2*%i]; +xn=dft(XDFT,1) +for i=1:length(xn) + zn(i)=xn(i)*%e^((%i*%pi*(i-1))/2); +end +disp(zn,'The IDFT of XDFT[k-1] is'); +ZDFT=[2*%i 4 -2*%i 0]; +zn1=dft(ZDFT,1) +//b2)periodic convolution +HDFT=(convol(XDFT,XDFT)) +HDFT=[HDFT,zeros(8:12)]; +HDFT=[HDFT(1:4);HDFT(5:8);HDFT(9:12)]; +HDFT1=[0 0 0 0]; +for i=1:4 + for j=1:3 + HDFT1(i)=HDFT1(i)+HDFT(j,i); + end +end +HDFT1; +hn=dft(HDFT1,1) +hn1=4*(xn.*xn); +disp(hn1,'The IDFT of XDFT*XDFT is'); +//b3)product +WDFT=XDFT.*XDFT; +wn=dft(WDFT,1) +wn1=convol(xn,xn); +wn1=[wn1,zeros(8:12)]; +wn1=[wn1(1:4);wn1(5:8);wn1(9:12)]; +WN=[0 0 0 0]; +for i=1:4 + for j=1:3 + WN(i)=WN(i)+wn1(j,i); + end +end +disp(WN,'The IDFT of XDFT.XDFT is'); +//b4)Central ordinates and signal Energy +E=0; +for i=1:length(xn) + E=E+abs(xn(i)^2); +end +disp(E,'the signal energy is');
\ No newline at end of file diff --git a/40/CH8/EX8.5c/Exa_8_5c.sce b/40/CH8/EX8.5c/Exa_8_5c.sce index bc4c62f5d..b7214bd03 100755 --- a/40/CH8/EX8.5c/Exa_8_5c.sce +++ b/40/CH8/EX8.5c/Exa_8_5c.sce @@ -1,7 +1,7 @@ -//Regular convolution
-xn=[1 2 1 0];
-yn=[1 2 1 0 0 0 0];
-YDFT=dft(yn,-1)
-SDFT=YDFT.*YDFT
-sn=dft(SDFT,1)
+//Regular convolution +xn=[1 2 1 0]; +yn=[1 2 1 0 0 0 0]; +YDFT=fft(yn,-1) +SDFT=YDFT.*YDFT +sn=fft(SDFT,1) sn1=convol(xn,xn)
\ No newline at end of file diff --git a/40/CH8/EX8.6/Exa_8_6.sce b/40/CH8/EX8.6/Exa_8_6.sce index be5c3cbb9..2b63a0678 100755 --- a/40/CH8/EX8.6/Exa_8_6.sce +++ b/40/CH8/EX8.6/Exa_8_6.sce @@ -1,20 +1,20 @@ -//Signal and spectrum replication
-xn=[2 3 2 1];
-XDFT=dft(xn,-1)
-yn=[xn xn xn];
-YDFT=dft(yn,-1)
-YDFT1=3*[XDFT(1:1/3:length(XDFT))];
-for i=2:3
- YDFT1(i:3:length(YDFT1))=0;
-end
-YDFT1(12:-1:11)=0;
-disp(YDFT1,'the DFT of x[n/3] is');
-hn=[xn(1:1/3:length(xn))]
-for i=2:3
- hn(i:3:length(hn))=0;
-end
-hn(12:-1:11)=0;
-hn
-HDFT=dft(hn,-1)
-HDFT1=[XDFT;XDFT;XDFT];
+//Signal and spectrum replication +xn=[2 3 2 1]; +XDFT=fft(xn,-1) +yn=[xn xn xn]; +YDFT=fft(yn,-1) +YDFT1=3*[XDFT(1:1/3:length(XDFT))]; +for i=2:3 + YDFT1(i:3:length(YDFT1))=0; +end +YDFT1(12:-1:11)=0; +disp(YDFT1,'the DFT of x[n/3] is'); +hn=[xn(1:1/3:length(xn))] +for i=2:3 + hn(i:3:length(hn))=0; +end +hn(12:-1:11)=0; +hn +HDFT=fft(hn,-1) +HDFT1=[XDFT;XDFT;XDFT]; disp(HDFT1,'the DFT of y[n]=[x[n],x[n],x[n]] is');
\ No newline at end of file diff --git a/40/CH8/EX8.7/Exa_8_7.sce b/40/CH8/EX8.7/Exa_8_7.sce index 9d9c9e16d..6a7f5a57c 100755 --- a/40/CH8/EX8.7/Exa_8_7.sce +++ b/40/CH8/EX8.7/Exa_8_7.sce @@ -1,7 +1,7 @@ -//relating DFT and IDFT
-XDFT1=[4 -2*%i 0 2*%i];
-xn1=dft(XDFT1,1);
-disp(xn1,'The IDFT of XDFT1');
-XDFT2=[12 -24*%i 0 4*%e^(%i*%pi/4) 0 4*%e^(-%i*%pi/4) 0 24*%i];
-xn2=dft(XDFT2,1);
-disp(xn2,'The IDFT of XDFT1');
\ No newline at end of file +//relating DFT and IDFT +XDFT1=[4 -2*%i 0 2*%i]; +xn1=fft(XDFT1,1); +disp(xn1,'The IDFT of XDFT1'); +XDFT2=[12 -24*%i 0 4*%e^(%i*%pi/4) 0 4*%e^(-%i*%pi/4) 0 24*%i]; +xn2=fft(XDFT2,1); +disp(xn2,'The IDFT of XDFT1');
\ No newline at end of file diff --git a/40/CH8/EX8.8/Exa_8_8.sce b/40/CH8/EX8.8/Exa_8_8.sce index 7fad7f114..47c388aed 100755 --- a/40/CH8/EX8.8/Exa_8_8.sce +++ b/40/CH8/EX8.8/Exa_8_8.sce @@ -1,9 +1,9 @@ -//Relating DFT and DTFT
-xn=[1 2 1 0];
-XDFT=dft(xn,-1);
-//for F=k/4,k=0,1,2,3
-for k=1:4
- XF(k)=1+2*%e^(-%i*%pi*(k-1)/2)+%e^(-%i*%pi*(k-1));
-end
-XF,XDFT
-disp(XF,'The DFT of x[n] is');
+//Relating DFT and DTFT +xn=[1 2 1 0]; +XDFT=fft(xn,-1); +//for F=k/4,k=0,1,2,3 +for k=1:4 + XF(k)=1+2*%e^(-%i*%pi*(k-1)/2)+%e^(-%i*%pi*(k-1)); +end +XF,XDFT +disp(XF,'The DFT of x[n] is');
\ No newline at end of file diff --git a/40/CH8/EX8.9a/Exa_8_9a.sce b/40/CH8/EX8.9a/Exa_8_9a.sce index b61b2c4d9..176cd645c 100755 --- a/40/CH8/EX8.9a/Exa_8_9a.sce +++ b/40/CH8/EX8.9a/Exa_8_9a.sce @@ -1,15 +1,15 @@ -//DFT and DFS of sinusoids
-n2=0:0.5/1000:5.5/100;
-xt=4*cos(100*%pi*n2');
-n=0:(0.5)/100:(5.5)/100;//F=3/12 hence N=12
-xn=4*cos(100*%pi*n');
-XDFT=dft(xn,-1);
-n1=0:11;
-a=gca();
-a.x_location="origin";
-plot2d(n2,xt);
-plot2d3('gnn',n,xn);
-xset('window',1);
-b=gca();
-b.x_location="origin";
-plot2d3('gnn',n1,XDFT);
+//DFT and DFS of sinusoids +n2=0:0.5/1000:5.5/100; +xt=4*cos(100*%pi*n2'); +n=0:(0.5)/100:(5.5)/100;//F=3/12 hence N=12 +xn=4*cos(100*%pi*n'); +XDFT=fft(xn,-1); +n1=0:11; +a=gca(); +a.x_location="origin"; +plot2d(n2,xt); +plot2d3('gnn',n,xn); +xset('window',1); +b=gca(); +b.x_location="origin"; +plot2d3('gnn',n1,XDFT);
\ No newline at end of file diff --git a/40/CH8/EX8.9b/Exa_8_9b.sce b/40/CH8/EX8.9b/Exa_8_9b.sce index d32e7094c..48e9487cc 100755 --- a/40/CH8/EX8.9b/Exa_8_9b.sce +++ b/40/CH8/EX8.9b/Exa_8_9b.sce @@ -1,15 +1,15 @@ -//DFT and DFS of sinusoids
-n2=0:1/1280:31/128;
-xt=4*sin(72*%pi*n2');
-n=0:1/128:31/128;//F=9/32 hence N=32
-xn=4*sin(72*%pi*n');
-XDFT=abs(dft(xn,-1));
-n1=0:31;
-a=gca();
-a.x_location="origin";
-plot2d(n2,xt);
-plot2d3('gnn',n,xn);
-xset('window',1);
-b=gca();
-b.x_location="origin";
-plot2d3('gnn',n1,XDFT);
+//DFT and DFS of sinusoids +n2=0:1/1280:31/128; +xt=4*sin(72*%pi*n2'); +n=0:1/128:31/128;//F=9/32 hence N=32 +xn=4*sin(72*%pi*n'); +XDFT=abs(fft(xn,-1)); +n1=0:31; +a=gca(); +a.x_location="origin"; +plot2d(n2,xt); +plot2d3('gnn',n,xn); +xset('window',1); +b=gca(); +b.x_location="origin"; +plot2d3('gnn',n1,XDFT);
\ No newline at end of file diff --git a/40/CH8/EX8.9c/Exa_8_9c.sce b/40/CH8/EX8.9c/Exa_8_9c.sce index 67632bb96..d504a0c70 100755 --- a/40/CH8/EX8.9c/Exa_8_9c.sce +++ b/40/CH8/EX8.9c/Exa_8_9c.sce @@ -1,15 +1,15 @@ -//DFT and DFS of sinusoids
-n2=0:1/840:6/21;
-xt=4*sin(72*%pi*n2')-6*cos(12*%pi*n2');
-n=0:1/21:6/21;//F=3/12 hence N=12
-xn=4*sin(72*%pi*n')-6*cos(12*%pi*n');
-XDFT=abs(dft(xn,-1));
-n1=0:6;
-a=gca();
-a.x_location="origin";
-plot2d(n2,xt);
-plot2d3('gnn',n,xn);
-xset('window',1);
-b=gca();
-b.x_location="origin";
-plot2d3('gnn',n1,XDFT);
+//DFT and DFS of sinusoids +n2=0:1/840:6/21; +xt=4*sin(72*%pi*n2')-6*cos(12*%pi*n2'); +n=0:1/21:6/21;//F=3/12 hence N=12 +xn=4*sin(72*%pi*n')-6*cos(12*%pi*n'); +XDFT=abs(fft(xn,-1)); +n1=0:6; +a=gca(); +a.x_location="origin"; +plot2d(n2,xt); +plot2d3('gnn',n,xn); +xset('window',1); +b=gca(); +b.x_location="origin"; +plot2d3('gnn',n1,XDFT);
\ No newline at end of file diff --git a/40/CH8/EX8.9d/Exa_8_9d.sce b/40/CH8/EX8.9d/Exa_8_9d.sce index 2d5d4b294..31c33c90d 100755 --- a/40/CH8/EX8.9d/Exa_8_9d.sce +++ b/40/CH8/EX8.9d/Exa_8_9d.sce @@ -1,15 +1,15 @@ -//DFT and DFS of sinusoids
-n2=0:1/2400:23/240;
-xt=1+4*sin(120*%pi*n2')+4*sin(40*%pi*n2');
-n=0:1/240:23/240;//F=9/32 hence N=32
-xn=1+4*sin(120*%pi*n')+4*sin(40*%pi*n');
-XDFT=abs(dft(xn,-1));
-n1=0:23;
-a=gca();
-a.x_location="origin";
-plot2d(n2,xt);
-plot2d3('gnn',n,xn);
-xset('window',1);
-b=gca();
-b.x_location="origin";
+//DFT and DFS of sinusoids +n2=0:1/2400:23/240; +xt=1+4*sin(120*%pi*n2')+4*sin(40*%pi*n2'); +n=0:1/240:23/240;//F=9/32 hence N=32 +xn=1+4*sin(120*%pi*n')+4*sin(40*%pi*n'); +XDFT=abs(fft(xn,-1)); +n1=0:23; +a=gca(); +a.x_location="origin"; +plot2d(n2,xt); +plot2d3('gnn',n,xn); +xset('window',1); +b=gca(); +b.x_location="origin"; plot2d3('gnn',n1,XDFT);
\ No newline at end of file |