From 8ac15bc5efafa2afc053c293152605b0e6ae60ff Mon Sep 17 00:00:00 2001 From: Siddharth Agarwal Date: Tue, 3 Sep 2019 18:27:40 +0530 Subject: Xcos examples from textbooks and for blocks --- Working_Examples/215/CH18/EX18.1/Figure18_1.jpg | Bin 0 -> 88485 bytes Working_Examples/215/CH18/EX18.1/ex18_1.sce | 45 +++++++++++++++++++++ Working_Examples/215/CH18/EX18.2/Figure18_2.jpg | Bin 0 -> 38313 bytes .../215/CH18/EX18.2/Figure18_2_xcos.jpg | Bin 0 -> 20230 bytes Working_Examples/215/CH18/EX18.2/ex18_2.xcos | 1 + Working_Examples/215/CH18/EX18.5/Figure18_5.jpg | Bin 0 -> 45713 bytes Working_Examples/215/CH18/EX18.5/ex18_5.sce | 34 ++++++++++++++++ Working_Examples/215/CH18/EX18.6/ex18_6.sce | 20 +++++++++ Working_Examples/215/CH18/EX18.8/Figure18_8.jpg | Bin 0 -> 30504 bytes .../215/CH18/EX18.8/Figure18_8_xcos.jpg | Bin 0 -> 13240 bytes Working_Examples/215/CH18/EX18.8/ex18_8.xcos | 1 + 11 files changed, 101 insertions(+) create mode 100755 Working_Examples/215/CH18/EX18.1/Figure18_1.jpg create mode 100755 Working_Examples/215/CH18/EX18.1/ex18_1.sce create mode 100755 Working_Examples/215/CH18/EX18.2/Figure18_2.jpg create mode 100755 Working_Examples/215/CH18/EX18.2/Figure18_2_xcos.jpg create mode 100755 Working_Examples/215/CH18/EX18.2/ex18_2.xcos create mode 100755 Working_Examples/215/CH18/EX18.5/Figure18_5.jpg create mode 100755 Working_Examples/215/CH18/EX18.5/ex18_5.sce create mode 100755 Working_Examples/215/CH18/EX18.6/ex18_6.sce create mode 100755 Working_Examples/215/CH18/EX18.8/Figure18_8.jpg create mode 100755 Working_Examples/215/CH18/EX18.8/Figure18_8_xcos.jpg create mode 100755 Working_Examples/215/CH18/EX18.8/ex18_8.xcos (limited to 'Working_Examples/215/CH18') diff --git a/Working_Examples/215/CH18/EX18.1/Figure18_1.jpg b/Working_Examples/215/CH18/EX18.1/Figure18_1.jpg new file mode 100755 index 0000000..c74d5e8 Binary files /dev/null and b/Working_Examples/215/CH18/EX18.1/Figure18_1.jpg differ diff --git a/Working_Examples/215/CH18/EX18.1/ex18_1.sce b/Working_Examples/215/CH18/EX18.1/ex18_1.sce new file mode 100755 index 0000000..67b8d26 --- /dev/null +++ b/Working_Examples/215/CH18/EX18.1/ex18_1.sce @@ -0,0 +1,45 @@ +clear +close +clc +//Example 18.1 +//From the figure 18.2 +disp('The equation of v(t) considering one period can be written as') +disp('v(t)=Vm*cos(5*%pi*t) for -0.1<=t<=0.1') +disp('v(t)=0 for 0.1<=t<=0.3') +//Assuming the value of Vm is 1 + +//Evaluating the constants an and bn +//bn=0 for all n +//an=(2*Vm*cos(n*%pi/2))/(%pi*(1-n^2)) +//a0=Vm/%pi +t=-1:0.02:1; +Vm=ones(1,length(t)); +v0t=Vm/%pi; +v1t=(Vm.*cos(5*%pi*t)).*0.5; +v0t_v1t=v0t+v1t; +v2t=(2/(3*%pi))*(Vm.*cos(10*%pi*t)); +v0t_v1t_v2t=v0t+v1t+v2t; +v3t=(2/(15*%pi))*(Vm.*cos(20*%pi*t)); +v0t_v1t_v2t_v3t=v0t+v1t+v2t-v3t; +figure +a = gca (); +a. y_location = "origin"; +a. x_location = "origin"; +a. data_bounds =[ -1,0;1 0.5]; +plot (t,v0t) +xtitle('vot vs t','t in s','vot') +figure +a = gca (); +a. y_location = "origin"; +a. x_location = "origin"; +a. data_bounds =[ -1,-0.5;1 0.5]; +plot (t,v0t_v1t) +a. y_location = "origin"; +a. x_location = "origin"; +a. data_bounds =[ -1,-0.5;1 0.5]; +plot (t,v0t_v1t_v2t,'r.->') +a. y_location = "origin"; +a. x_location = "origin"; +a. data_bounds =[ -1,-0.5;1 0.5]; +plot (t,v0t_v1t_v2t_v3t,'d') +xtitle('v(t)','t in s','v(t) in V') \ No newline at end of file diff --git a/Working_Examples/215/CH18/EX18.2/Figure18_2.jpg b/Working_Examples/215/CH18/EX18.2/Figure18_2.jpg new file mode 100755 index 0000000..16292c9 Binary files /dev/null and b/Working_Examples/215/CH18/EX18.2/Figure18_2.jpg differ diff --git a/Working_Examples/215/CH18/EX18.2/Figure18_2_xcos.jpg b/Working_Examples/215/CH18/EX18.2/Figure18_2_xcos.jpg new file mode 100755 index 0000000..72970e2 Binary files /dev/null and b/Working_Examples/215/CH18/EX18.2/Figure18_2_xcos.jpg differ diff --git a/Working_Examples/215/CH18/EX18.2/ex18_2.xcos b/Working_Examples/215/CH18/EX18.2/ex18_2.xcos new file mode 100755 index 0000000..6acbccd --- /dev/null +++ b/Working_Examples/215/CH18/EX18.2/ex18_2.xcos @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Working_Examples/215/CH18/EX18.5/Figure18_5.jpg b/Working_Examples/215/CH18/EX18.5/Figure18_5.jpg new file mode 100755 index 0000000..ef0a506 Binary files /dev/null and b/Working_Examples/215/CH18/EX18.5/Figure18_5.jpg differ diff --git a/Working_Examples/215/CH18/EX18.5/ex18_5.sce b/Working_Examples/215/CH18/EX18.5/ex18_5.sce new file mode 100755 index 0000000..580a1f6 --- /dev/null +++ b/Working_Examples/215/CH18/EX18.5/ex18_5.sce @@ -0,0 +1,34 @@ +clc; +//Example 18.5 +//Let amplitude be 1 +A=1; +Dt=0.01; +T1=4; +t=0:Dt:T1/4; +for i=1:length(t) + xt(i)=A +end +//Calculate Fourier Transform +Wmax=2*%pi*1; +K=4; +k=-(2*K):(K/1000):(2*K); +W=k*Wmax/K; +xt=xt'; +XW=xt*exp(-sqrt(-1)*t'*W)*Dt; +XW_Mag=real(XW); +W=[-mtlb_fliplr(W),W(2:1001)]; +XW_Mag=[mtlb_fliplr(XW_Mag),XW_Mag(2:1001)]; +subplot(2,1,1); +a=gca(); +a.data_bounds=[0,0;1,1.5]; +a.y_location="origin"; +plot(t,xt); +xlabel('t in sec.'); +title('v(t)vs t'); +subplot(2,1,2); +a=gca(); +a.y_location="origin"; +plot(W*%pi/2,abs (XW_Mag)); +xlabel('Freq in rad/sec'); +ylabel('|F(jw)|') +title('|F(jw)| vs t'); \ No newline at end of file diff --git a/Working_Examples/215/CH18/EX18.6/ex18_6.sce b/Working_Examples/215/CH18/EX18.6/ex18_6.sce new file mode 100755 index 0000000..91ce75c --- /dev/null +++ b/Working_Examples/215/CH18/EX18.6/ex18_6.sce @@ -0,0 +1,20 @@ +clc +syms s t +printf("Given") +disp('v(t)=4*exp(-3*t)*u(t)') +v=4*exp(-3*t) + +F=4*(integ(exp(-(3+%i*1)*s),s,0,%inf)) +//The secind term tends to zero +disp(F,'F=') +//Let W be the total 1 ohm energy in the input signal +W=integ(v^2,t,0,%inf) +disp(W,'W=') +//Let Wo be the total energy +//As the frequency range is given as 1 Hz<|f|<2 Hz +//Considering symmetry +Wo=(1/%pi)*integ((16/(9+s^2)),s,2*%pi,4*%pi) +disp(Wo,'Wo=') + + + diff --git a/Working_Examples/215/CH18/EX18.8/Figure18_8.jpg b/Working_Examples/215/CH18/EX18.8/Figure18_8.jpg new file mode 100755 index 0000000..b56b076 Binary files /dev/null and b/Working_Examples/215/CH18/EX18.8/Figure18_8.jpg differ diff --git a/Working_Examples/215/CH18/EX18.8/Figure18_8_xcos.jpg b/Working_Examples/215/CH18/EX18.8/Figure18_8_xcos.jpg new file mode 100755 index 0000000..9fe790d Binary files /dev/null and b/Working_Examples/215/CH18/EX18.8/Figure18_8_xcos.jpg differ diff --git a/Working_Examples/215/CH18/EX18.8/ex18_8.xcos b/Working_Examples/215/CH18/EX18.8/ex18_8.xcos new file mode 100755 index 0000000..faf272f --- /dev/null +++ b/Working_Examples/215/CH18/EX18.8/ex18_8.xcos @@ -0,0 +1 @@ + \ No newline at end of file -- cgit