summaryrefslogtreecommitdiff
path: root/2279/CH5/EX5.7
diff options
context:
space:
mode:
authorprashantsinalkar2017-10-10 12:27:19 +0530
committerprashantsinalkar2017-10-10 12:27:19 +0530
commit7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 (patch)
treedbb9e3ddb5fc829e7c5c7e6be99b2c4ba356132c /2279/CH5/EX5.7
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/CH5/EX5.7')
-rw-r--r--2279/CH5/EX5.7/Ex5_7.sce50
1 files changed, 50 insertions, 0 deletions
diff --git a/2279/CH5/EX5.7/Ex5_7.sce b/2279/CH5/EX5.7/Ex5_7.sce
new file mode 100644
index 000000000..b1a9f8517
--- /dev/null
+++ b/2279/CH5/EX5.7/Ex5_7.sce
@@ -0,0 +1,50 @@
+//Fourier Series coefficients of half-wave rectifier output
+//Assume the period of the signal T=1
+t=-0.5:0.01:1;
+T = 1;
+for i=1:length(t)
+ if t(i)<T/2 then
+ x(i)=sin(2*%pi*t(i));
+ else
+ x(i)=0;
+ end
+end
+k=-10:10;
+for i=1:length(k)
+ if k(i)==1 then
+ ak(i)=1/(4*%i);
+ elseif k(i)==-1
+ ak(i)=-1/(4*%i);
+ else
+ ak(i)=(cos(k(i)*%pi/2)*exp(-k(i)*%pi/2*-%i))/(%pi-(%pi*k(i)*k(i)));
+ end
+end
+
+
+disp("The fourier series coefficients are...")
+disp(ak)
+disp("magnitude of Fourier series coefficient")
+disp(abs(ak))
+//PLotting frequency spectrum
+subplot(2,1,1)
+plot(k,abs(ak),'.');
+xtitle("Magnitude Spectrum","k","|ak|");
+for i=1:length(k)
+ if k(i)==0 | k(i)==3 | k(i)==-3 | k(i)==-5 |k(i)==5 then
+ phase(i)=0;
+ elseif k(i)==-1 then
+ phase(i)=%pi/2;
+ elseif k(i)==1 then
+ phase(i)=-%pi/2;
+ elseif k(i)==-2 | k(i)==-4
+ phase(i)=%pi;
+ elseif k(i)==2 | k(i)==4
+ phase(i)=-%pi;
+ else
+ phase(i) = 0;
+ end
+end
+subplot(2,1,2)
+plot(k,phase,'.');
+xtitle("Phase Spectrum","k","angle(ak)");
+disp(phase) \ No newline at end of file