summaryrefslogtreecommitdiff
path: root/Working_Examples/3432/CH3/EX3.4
diff options
context:
space:
mode:
authorSiddharth Agarwal2019-09-03 18:27:40 +0530
committerSiddharth Agarwal2019-09-03 18:27:40 +0530
commit8ac15bc5efafa2afc053c293152605b0e6ae60ff (patch)
treee1bc17aae137922b1ee990f17aae4a6cb15b7d87 /Working_Examples/3432/CH3/EX3.4
parent52a477ec613900885e29c4a0b02806a415b4f83a (diff)
downloadXcos_block_examples-master.tar.gz
Xcos_block_examples-master.tar.bz2
Xcos_block_examples-master.zip
Xcos examples from textbooks and for blocksHEADmaster
Diffstat (limited to 'Working_Examples/3432/CH3/EX3.4')
-rwxr-xr-xWorking_Examples/3432/CH3/EX3.4/DEPENDENCIES/fig_settings.sci9
-rwxr-xr-xWorking_Examples/3432/CH3/EX3.4/Ex3_4.sce65
-rwxr-xr-xWorking_Examples/3432/CH3/EX3.4/Ex3_4_f0.pdfbin0 -> 23237 bytes
-rwxr-xr-xWorking_Examples/3432/CH3/EX3.4/Ex3_4_f1.pdfbin0 -> 20300 bytes
4 files changed, 74 insertions, 0 deletions
diff --git a/Working_Examples/3432/CH3/EX3.4/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH3/EX3.4/DEPENDENCIES/fig_settings.sci
new file mode 100755
index 0000000..5d5e7d4
--- /dev/null
+++ b/Working_Examples/3432/CH3/EX3.4/DEPENDENCIES/fig_settings.sci
@@ -0,0 +1,9 @@
+//------------------------------------------------------------------
+//figure handel settings
+f=get("current_figure"); //Current figure handle
+f.background=8; //make the figure window background white
+l=f.children(1);
+l.background=8 ;//make the text background white
+id=color('grey');
+xgrid(id);
+//------------------------------------------------------------------
diff --git a/Working_Examples/3432/CH3/EX3.4/Ex3_4.sce b/Working_Examples/3432/CH3/EX3.4/Ex3_4.sce
new file mode 100755
index 0000000..dacf05a
--- /dev/null
+++ b/Working_Examples/3432/CH3/EX3.4/Ex3_4.sce
@@ -0,0 +1,65 @@
+//Example 3.4
+//Frequency response
+
+xdel(winsid())//close all graphics Windows
+clear;
+clc;
+//------------------------------------------------------------------
+//(a) Frequency response of 1/(s+k)
+k=1;
+fmin=1e-2;
+fmax=1e2;
+// Transfer function
+s=poly(0,'s');
+sysH=syslin('c',1/(s+k))
+
+//Frequency response for k=1
+//Note that - magnitude plot semilog plot unlike log-log plot in the book.
+bode(sysH,fmin,fmax)
+title('Frequency response for k=1','fontsize',3)
+
+//------------------------------------------------------------------
+//(b) Response to u=sin(10*t);
+t=0:0.02:10;
+u=sin(10*t);
+y=csim(u,t,sysH);
+figure, plot(t,y)
+
+//Title, labels and grid to the figure
+exec .\fig_settings.sci; // custom script for setting figure properties
+title('Complete transient response','fontsize',3)
+xlabel('Time (sec.)','fontsize',2)
+ylabel('Output','fontsize',2)
+
+//phase lag
+figure, plot(t,y)
+plot(t,u,'r')
+zoom_rect([9 -1 10 1])
+exec .\fig_settings.sci; // custom script for setting figure properties
+title('Phase lag between output and input','fontsize',3)
+xlabel('Time (sec.)','fontsize',2)
+ylabel('Output, Input','fontsize',2)
+h=legend('y(t)','u(t)')
+h.legend_location = "in_upper_right"
+h.fill_mode='off'
+
+// time lag
+w=find(t>=9.4 & t<=10);
+T=t(w);
+Y=y(w);
+U=u(w);
+wu=find(U==max(U))
+wy=find(Y==max(Y))
+
+//Responses
+plot2d3(T(wy),Y(wy))
+plot2d3(T(wu),U(wu))
+delta_t=T(wu)-T(wy); //time lag sec.
+xstring(9.64,-0.1,"$\delta t$",0,0)
+xarrows([9.58;9.72], [0;0], 0.7, 1)
+xarrows([9.72;9.58], [0;0], 0.7, 1)
+t=get("hdl")
+disp(abs(delta_t), "Time lag of output in sec. is")
+disp(abs(delta_t)*10, "Phase lag of output in radians is")
+
+//------------------------------------------------------------------
diff --git a/Working_Examples/3432/CH3/EX3.4/Ex3_4_f0.pdf b/Working_Examples/3432/CH3/EX3.4/Ex3_4_f0.pdf
new file mode 100755
index 0000000..8910b81
--- /dev/null
+++ b/Working_Examples/3432/CH3/EX3.4/Ex3_4_f0.pdf
Binary files differ
diff --git a/Working_Examples/3432/CH3/EX3.4/Ex3_4_f1.pdf b/Working_Examples/3432/CH3/EX3.4/Ex3_4_f1.pdf
new file mode 100755
index 0000000..1a5b20a
--- /dev/null
+++ b/Working_Examples/3432/CH3/EX3.4/Ex3_4_f1.pdf
Binary files differ