summaryrefslogtreecommitdiff
path: root/758/CH2
diff options
context:
space:
mode:
Diffstat (limited to '758/CH2')
-rwxr-xr-x758/CH2/EX2.1/Ex_2_1.sce26
-rwxr-xr-x758/CH2/EX2.2/Ex_2_2.sce26
-rwxr-xr-x758/CH2/EX2.3/Ex_2_3.sce27
-rwxr-xr-x758/CH2/EX2.4/Ex_2_4.sce26
-rwxr-xr-x758/CH2/EX2.5/Ex_2_5.sce27
-rwxr-xr-x758/CH2/EX2.6/Ex_2_6.sce52
-rwxr-xr-x758/CH2/EX2.8/Ex_2_8.sce20
7 files changed, 204 insertions, 0 deletions
diff --git a/758/CH2/EX2.1/Ex_2_1.sce b/758/CH2/EX2.1/Ex_2_1.sce
new file mode 100755
index 000000000..1f60ffd26
--- /dev/null
+++ b/758/CH2/EX2.1/Ex_2_1.sce
@@ -0,0 +1,26 @@
+//Example 2.1
+
+clc;clear;close;
+A=1;T=2;
+w0=2*%pi/T;
+
+//Calculation of trignometric fourier series co-efficients
+a0=A/T*(integrate('-1','t',-T/2,-T/4)+integrate('+1','t',-T/4,T/4)+integrate('-1','t',T/4,T/2));
+for n=1:10;
+a(1,n)=2*A/T*(integrate('-cos(n*w0*t)','t',-T/2,-T/4)+integrate('+cos(n*w0*t)','t',-T/4,T/4)+integrate('-cos(n*w0*t)','t',T/4,T/2));
+b(1,n)=2*A/T*(integrate('-sin(n*w0*t)','t',-T/2,-T/4)+integrate('+sin(n*w0*t)','t',-T/4,T/4)+integrate('-sin(n*w0*t)','t',T/4,T/2));
+end
+
+//Displaying fourier coefficients
+disp(T,'fundamental period T= ',A,'Assumption: Amplitude A= ');
+disp('Tignometric fourier series co-efficients:');
+disp(a0,'a0= ');disp(a,'an= ');disp(b,'bn= ');
+
+x=[-A*ones(1,25) A*ones(1,50) -A*ones(1,25)] //Function for ploting purpose
+t=-T/2:0.01*T:T/2-0.01;
+subplot(311);plot(t,x);
+title('x(t)');xlabel('time t');
+subplot(312);plot2d3(a);
+title('Coefficients an');xlabel('n');
+subplot(313);plot2d3(b);
+title('Coefficients bn');xlabel('n'); \ No newline at end of file
diff --git a/758/CH2/EX2.2/Ex_2_2.sce b/758/CH2/EX2.2/Ex_2_2.sce
new file mode 100755
index 000000000..cd3dea2cf
--- /dev/null
+++ b/758/CH2/EX2.2/Ex_2_2.sce
@@ -0,0 +1,26 @@
+//Example 2.2
+
+clc;clear;close;
+A=1;T=2;
+w0=2*%pi/T;
+
+//Calculation of trignometric fourier series co-efficients
+a0=A/T*integrate('1','t',-T/4,T/4);
+for n=1:10;
+a(1,n)=2*A/T*integrate('cos(n*w0*t)','t',-T/4,T/4);
+b(1,n)=2*A/T*integrate('sin(n*w0*t)','t',-T/4,T/4);
+end
+
+//Displaying fourier coefficients
+disp(T,'fundamental period T= ',A,'Assumption: Amplitude A= ');
+disp('Tignometric fourier series co-efficients:');
+disp(a0,'a0= ');disp(a,'an= ');disp(b,'bn= ');
+
+x=[zeros(1,25) A*ones(1,50) zeros(1,25)];
+t=-T/2:0.01*T:T/2-0.01;
+subplot(311);plot(t,x);
+title('x(t)');xlabel('time t');
+subplot(312);plot2d3(a);
+title('Coefficients an');xlabel('n');
+subplot(313);plot2d3(b);
+title('Coefficients bn');xlabel('n'); \ No newline at end of file
diff --git a/758/CH2/EX2.3/Ex_2_3.sce b/758/CH2/EX2.3/Ex_2_3.sce
new file mode 100755
index 000000000..db875d974
--- /dev/null
+++ b/758/CH2/EX2.3/Ex_2_3.sce
@@ -0,0 +1,27 @@
+//Example 2.3
+
+clc;clear;close;
+A=1;T=2;
+w0=2*%pi/T;
+
+//Calculation of trignometric fourier series co-efficients
+a0=A/T*integrate('sin(w0*t)','t',0,T/2);
+for n=1:10;
+a(1,n)=2*A/T*integrate('sin(w0*t)*cos(n*w0*t)','t',0,T/2);
+b(1,n)=2*A/T*integrate('sin(w0*t)*sin(n*w0*t)','t',0,T/2);
+end
+
+//Displaying fourier coefficients
+disp(T,'fundamental period T= ',A,'Assumption: Amplitude A= ');
+disp('Tignometric fourier series co-efficients:');
+disp(a0,'a0= ');disp(a,'an= ');disp(b,'bn= ');
+
+t=0:0.01*T:T/2;
+x=[A*sin(w0*t) zeros(1,50)];
+t=0:0.01*T:T;
+subplot(311);plot(t,x);
+title('x(t)');xlabel('time t');
+subplot(312);plot2d3(a);
+title('Coefficients an');xlabel('n');
+subplot(313);plot2d3(b);
+title('Coefficients bn');xlabel('n'); \ No newline at end of file
diff --git a/758/CH2/EX2.4/Ex_2_4.sce b/758/CH2/EX2.4/Ex_2_4.sce
new file mode 100755
index 000000000..fb1bcd1bf
--- /dev/null
+++ b/758/CH2/EX2.4/Ex_2_4.sce
@@ -0,0 +1,26 @@
+//Example 2.4
+
+clc;clear;close;
+A=1;T=2;
+w0=2*%pi/T;
+
+//Calculation of trignometric fourier series co-efficients
+a0=4*A/T*(integrate('t-0.5*T','t',-T/2,-T/4)+integrate('t','t',-T/4,T/4)+integrate('-t+0.5*T','t',T/4,T/2));
+for n=1:10;
+a(1,n)=2*4*A/T*(integrate('(t-0.5*T)*cos(n*w0*t)','t',-T/2,-T/4)+integrate('t*cos(n*w0*t)','t',-T/4,T/4)+integrate('(-t+0.5*T)*cos(n*w0*t)','t',T/4,T/2));
+b(1,n)=2*4*A/T*(integrate('(t-0.5*T)*sin(n*w0*t)','t',-T/2,-T/4)+integrate('t*sin(n*w0*t)','t',-T/4,T/4)+integrate('(-t+0.5*T)*sin(n*w0*t)','t',T/4,T/2));
+end
+
+//Displaying fourier coefficients
+disp(T,'fundamental period T= ',A,'Assumption: Amplitude A= ');
+disp('Tignometric fourier series co-efficients:');
+disp(a0,'a0= ');disp(a,'an= ');disp(b,'bn= ');
+
+t=-T/2:0.01*T:T/2;
+x=[-4*A/T*t(1:25)-2*A 4*A/T*t(26:75) -4*A/T*t(76:101)+2*A];
+subplot(311);plot(t,x);
+title('x(t)');xlabel('time t');
+subplot(312);plot2d3(a);
+title('Coefficients an');xlabel('n');
+subplot(313);plot2d3(b);
+title('Coefficients bn');xlabel('n'); \ No newline at end of file
diff --git a/758/CH2/EX2.5/Ex_2_5.sce b/758/CH2/EX2.5/Ex_2_5.sce
new file mode 100755
index 000000000..e800c80e7
--- /dev/null
+++ b/758/CH2/EX2.5/Ex_2_5.sce
@@ -0,0 +1,27 @@
+//Example 2.5
+
+clc;clear;close;
+A=1;T=2;d=0.1;
+w0=2*%pi/T;
+
+//Calculation of trignometric fourier series co-efficients
+a0=A/T*integrate('1','t',-T/4,T/4);
+for n=1:10;
+a(1,n)=2*A/T*integrate('cos(n*w0*t)','t',-d/2,d/2);
+b(1,n)=2*A/T*integrate('sin(n*w0*t)','t',-d/2,d/2);
+end
+
+//Displaying fourier coefficients
+disp(d,'pulse width d= ',T,'fundamental period T= ',A,'Assumption: Amplitude A= ');
+disp('Tignometric fourier series co-efficients:');
+disp(a0,'a0= ');disp(a,'an= ');disp(b,'bn= ');
+
+n=round(50*d/T); //Variable used for plotting pulses accurately
+x=[zeros(1,50-n) A*ones(1,2*n+1) zeros(1,50-n)]
+t=-T/2:0.01*T:T/2;
+subplot(311);plot(t,x);
+title('x(t)');xlabel('time t');
+subplot(312);plot2d3(a);
+title('Coefficients an');xlabel('n');
+subplot(313);plot2d3(b);
+title('Coefficients bn');xlabel('n'); \ No newline at end of file
diff --git a/758/CH2/EX2.6/Ex_2_6.sce b/758/CH2/EX2.6/Ex_2_6.sce
new file mode 100755
index 000000000..1dc8f41fc
--- /dev/null
+++ b/758/CH2/EX2.6/Ex_2_6.sce
@@ -0,0 +1,52 @@
+//Example 2.6
+
+clc;clear;close;
+A=1;T=2;
+w0=2*%pi/T;
+
+//Calculation of trignometric fourier series co-efficients
+a0=A/T*(integrate('-1','t',-T/2,0)+integrate('+1','t',0,T/2));
+for n=1:10
+a(1,n)=2*A/T*(integrate('-cos(n*w0*t)','t',-T/2,0)+integrate('+cos(n*w0*t)','t',0,T/2));
+b(1,n)=2*A/T*(integrate('-sin(n*w0*t)','t',-T/2,0)+integrate('+sin(n*w0*t)','t',0,T/2));
+end
+a=clean(a);b=clean(b); //Function used to round small entities to zero
+
+//Calculation of exponential fourier series co-efficients
+function y=f(t),y=complex(cos(n*w0*t),-sin(n*w0*t)),endfunction;
+for n=-10:10
+c(1,n+11)=A/T*(-1*intc(-T/2,0,f)+intc(0,T/2,f));
+end
+c=clean(c); //Function used to round small entities to zero
+
+//Calculation of trignometric fourier series co-efficients from exponential fourie series coefficients
+a01=c(1);
+a1=2*real(c(12:21));
+b1=-2*imag(c(12:21));
+
+//Displaying fourier coefficients
+disp(T,'fundamental period T= ',A,'Assumption: Amplitude A= ');
+disp('Tignometric fourier series co-efficients:');
+disp(a0,'a0= ');disp(a,'an= ');disp(b,'bn= ');
+disp('Exponential fourier series co-efficients');
+disp(c(11),'c0= ');disp(c(12:21),'cn= ');disp(c(10:-1:1),'c-n= ');
+disp('Trignometric fourier series co-efficients from exponential coefficients:');
+disp(a01,'a0= ');disp(a1,'an= ');disp(b1,'bn= ');
+disp('The co-effifcients obtained are same by both methods')
+
+x=[-A*ones(1,50) A*ones(1,51)];
+t=-T/2:0.01*T:T/2;
+n=-10:10;
+subplot(311);plot(t,x);
+title('x(t)');xlabel('time t');
+subplot(312);plot2d3(a);
+title('Coefficients an');xlabel('n');
+subplot(313);plot2d3(b);
+title('Coefficients bn');xlabel('n');
+figure;
+subplot(311);plot(t,x);
+title('x(t)');xlabel('time t');
+subplot(312);plot2d3(n,abs(c));
+title('Magnitude of Coefficients |c|');xlabel('n');
+subplot(313);plot2d3(n,atan(c));
+title('Phase of Coefficients /_c');xlabel('n'); \ No newline at end of file
diff --git a/758/CH2/EX2.8/Ex_2_8.sce b/758/CH2/EX2.8/Ex_2_8.sce
new file mode 100755
index 000000000..a5b6253a1
--- /dev/null
+++ b/758/CH2/EX2.8/Ex_2_8.sce
@@ -0,0 +1,20 @@
+//Example 2.8
+
+clc;clear;close;
+t=poly(0,'t');
+//cn=3/(4+(n*%pi)^2)
+Pt=0.669; //Total energy
+Preq=0.999*Pt; //Required energy
+c0=3/(4+(0*%pi)^2);
+disp(c0,'c0=');
+P=(abs(c0))^2;
+c=[];n=0;
+while P<Preq
+ n=n+1;
+ c(n)=3/(4+(n*%pi)^2);
+ disp(c(n),'cn=',n,'n=');
+ P=P+2*(abs(c(n)))^2;
+end
+disp(Pt,'Total power Pt=');
+disp(Preq,'99.9% of total power Preqd=');
+disp(n,'To iclude 99.9% of energy, we need to retain n terms where n='); \ No newline at end of file