diff options
author | prashantsinalkar | 2017-10-10 12:38:01 +0530 |
---|---|---|
committer | prashantsinalkar | 2017-10-10 12:38:01 +0530 |
commit | f35ea80659b6a49d1bb2ce1d7d002583f3f40947 (patch) | |
tree | eb72842d800ac1233e9d890e020eac5fd41b0b1b /842/CH3 | |
parent | 7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 (diff) | |
download | Scilab-TBC-Uploads-f35ea80659b6a49d1bb2ce1d7d002583f3f40947.tar.gz Scilab-TBC-Uploads-f35ea80659b6a49d1bb2ce1d7d002583f3f40947.tar.bz2 Scilab-TBC-Uploads-f35ea80659b6a49d1bb2ce1d7d002583f3f40947.zip |
updated the code
Diffstat (limited to '842/CH3')
-rwxr-xr-x | 842/CH3/EX3.10/Example3_10.sce | 76 | ||||
-rwxr-xr-x | 842/CH3/EX3.8/Example3_8.sce | 153 |
2 files changed, 114 insertions, 115 deletions
diff --git a/842/CH3/EX3.10/Example3_10.sce b/842/CH3/EX3.10/Example3_10.sce index 1731694d7..1fc41fae9 100755 --- a/842/CH3/EX3.10/Example3_10.sce +++ b/842/CH3/EX3.10/Example3_10.sce @@ -1,38 +1,38 @@ -//clear//
-//Example3.10:DTFS of x[n] =sin(Won)
-clear;
-close;
-clc;
-n = 0:0.01:5;
-N = 5;
-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.01)
- a(k+1)=0;
- end
-end
-a =a'
-a_conj = conj(a);
-ak = [a_conj($:-1:1),a(2:$)]
-k = -(N-2):(N-2);
-//
-figure
-a = gca();
-a.y_location = "origin";
-a.x_location = "origin";
-a.data_bounds=[-8,-1;8,1];
-poly1 = a.children(1).children(1);
-poly1.thickness = 3;
-plot2d3('gnn',k,-imag(ak),5)
-poly1 = a.children(1).children(1);
-poly1.thickness = 3;
-plot2d3('gnn',N+k,-imag(ak),5)
-poly1 = a.children(1).children(1);
-poly1.thickness = 3;
-plot2d3('gnn',-(N+k),-imag(ak($:-1:1)),5)
-poly1 = a.children(1).children(1);
-poly1.thickness = 3;
-title('ak')
+//clear// +//Example3.10:DTFS of x[n] =sin(Won) +clear; +close; +clc; +n = 0:0.01:5; +N = 5; +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.01) + a(k+1)=0; + end +end +a =a' +a_conj = conj(a); +ak = [a_conj($:-1:1),a(2:$)] +k = -(N-2):(N-2); +// +figure +a = gca(); +a.y_location = "origin"; +a.x_location = "origin"; +a.data_bounds=[-8,-1;8,1]; +poly1 = a; +poly1.thickness = 3; +plot2d3('gnn',k,-imag(ak),5) +poly1 = a; +poly1.thickness = 3; +plot2d3('gnn',N+k,-imag(ak),5) +poly1 = a.children(1).children(1); +poly1.thickness = 3; +plot2d3('gnn',-(N+k),-imag(ak($:-1:1)),5) +poly1 = a; +poly1.thickness = 3; +title('ak')
\ No newline at end of file diff --git a/842/CH3/EX3.8/Example3_8.sce b/842/CH3/EX3.8/Example3_8.sce index 981eb80ed..93da994c5 100755 --- a/842/CH3/EX3.8/Example3_8.sce +++ b/842/CH3/EX3.8/Example3_8.sce @@ -1,77 +1,76 @@ -//clear//
-//Example3.8:Fourier Series Representation of Periodic Impulse Train
-clear;
-clc;
-close;
-T =4;
-T1 = T/4;
-t = [-T,0,T];
-xt = [1,1,1]; //Generation of Periodic train of Impulses
-t1 = -T1:T1/100:T1;
-gt = ones(1,length(t1));//Generation of periodic square wave
-t2 = [-T1,0,T1];
-qt = [1,0,-1];//Derivative of periodic square wave
-Wo = 2*%pi/T;
-ak = 1/T;
-b(1) = 0;
-c(1) = 2*T1/T;
-for k =1:5
- b(k+1) = ak*(exp(sqrt(-1)*k*Wo*T1)-exp(-sqrt(-1)*k*Wo*T1));
- if(abs(b(k+1))<=0.1)
- b(k+1) =0;
- end
- c(k+1) = b(k+1)/(sqrt(-1)*k*Wo);
- if(abs(c(k+1))<=0.1)
- c(k+1) =0;
- end
-end
-k = 0:5
-disp('Fourier Series Coefficients of periodic Square Wave')
-disp(b)
-disp('Fourier Series Coefficients of derivative of periodic square wave')
-disp(c)
-//Plotting the periodic train of impulses
-figure
-subplot(3,1,1)
-a = gca();
-a.y_location = "origin";
-a.x_location = "origin";
-a.data_bounds=[-6,0;6,2];
-plot2d3('gnn',t,xt,5)
-poly1 = a.children(1).children(1);
-poly1.thickness = 3;
-title('x(t)')
-//Plotting the periodic square waveform
-subplot(3,1,2)
-a = gca();
-a.y_location = "origin";
-a.x_location = "origin";
-a.data_bounds=[-6,0;6,2];
-plot2d(t1,gt,5)
-poly1 = a.children(1).children(1);
-poly1.thickness = 3;
-plot2d(T+t1,gt,5)
-poly1 = a.children(1).children(1);
-poly1.thickness = 3;
-plot2d(-T+t1,gt,5)
-poly1 = a.children(1).children(1);
-poly1.thickness = 3;
-title('g(t)')
-//Plotting the periodic square waveform
-subplot(3,1,3)
-a = gca();
-a.y_location = "origin";
-a.x_location = "origin";
-a.data_bounds=[-6,-2;6,2];
-poly1 = a.children(1).children(1);
-poly1.thickness = 3;
-plot2d3('gnn',t2,qt,5)
-poly1 = a.children(1).children(1);
-poly1.thickness = 3;
-plot2d3('gnn',T+t2,qt,5)
-poly1 = a.children(1).children(1);
-poly1.thickness = 3;
-plot2d3('gnn',-T+t2,qt,5)
-poly1 = a.children(1).children(1);
-poly1.thickness = 3;
-title('q(t)')
+//clear// +//Example3.8:Fourier Series Representation of Periodic Impulse Train +clear; +clc; +close; +T =4; +T1 = T/4; +t = [-T,0,T]; +xt = [1,1,1]; //Generation of Periodic train of Impulses +t1 = -T1:T1/100:T1; +gt = ones(1,length(t1));//Generation of periodic square wave +t2 = [-T1,0,T1]; +qt = [1,0,-1];//Derivative of periodic square wave +Wo = 2*%pi/T; +ak = 1/T; +b(1) = 0; +c(1) = 2*T1/T; +for k =1:5 + b(k+1) = ak*(exp(sqrt(-1)*k*Wo*T1)-exp(-sqrt(-1)*k*Wo*T1)); + if(abs(b(k+1)) < =0.1) + b(k+1) =0; + end + c(k+1) = b(k+1)/(sqrt(-1)*k*Wo); + if(abs(c(k+1)) < =0.1) + c(k+1) =0; + end +end +k = 0:5 +disp('Fourier Series Coefficients of periodic Square Wave') +disp(b) +disp('Fourier Series Coefficients of derivative of periodic square wave') +disp(c) +//Plotting the periodic train of impulses +figure +subplot(3,1,1) +a = gca(); +a.y_location = "origin"; +a.x_location = "origin"; +a.data_bounds=[-6,0;6,2]; +plot2d3('gnn',t,xt,5) +poly1 = a.children(1).children(1); +poly1.thickness = 3; +title('x(t)') +//Plotting the periodic square waveform +subplot(3,1,2) +a = gca(); +a.y_location = "origin"; +a.x_location = "origin"; +a.data_bounds=[-6,0;6,2]; +plot2d(t1,gt,5) +poly1 = a.children(1).children(1); +poly1.thickness = 3; +plot2d(T+t1,gt,5) +poly1 = a.children(1).children(1); +poly1.thickness = 3; +plot2d(-T+t1,gt,5) +poly1 = a.children(1).children(1); +poly1.thickness = 3; +title('g(t)') +//Plotting the periodic square waveform +subplot(3,1,3) +a = gca(); +a.y_location = "origin"; +a.x_location = "origin"; +a.data_bounds=[-6,-2;6,2]; +poly1.thickness = 3; +plot2d3('gnn',t2,qt,5) +poly1 = a.children(1).children(1); +poly1.thickness = 3; +plot2d3('gnn',T+t2,qt,5) +poly1 = a.children(1).children(1); +poly1.thickness = 3; +plot2d3('gnn',-T+t2,qt,5) +poly1 = a.children(1).children(1); +poly1.thickness = 3; +title('q(t)')
\ No newline at end of file |