diff options
Diffstat (limited to 'Working_Examples/3432/CH3')
33 files changed, 656 insertions, 0 deletions
diff --git a/Working_Examples/3432/CH3/EX3.10/Ex3_10.sce b/Working_Examples/3432/CH3/EX3.10/Ex3_10.sce new file mode 100755 index 0000000..e34f28a --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.10/Ex3_10.sce @@ -0,0 +1,18 @@ +//Example 3.10
+
+//Computing final value for unstable system to show the incorrect
+// use of final value theorem.
+clear;
+clc;
+//------------------------------------------------------------------
+s=poly(0,'s');
+num=3;
+den=s*(s-2);
+Ys=syslin('c',num/den);
+
+//final value theorem, lim s-->0 in s*Y(s)
+Y_final=horner(s*Ys,0);
+disp(Y_final,"The final value of the output y is:");
+disp('The final value computed is incorrect as the system...
+ response is unbounded');
+//------------------------------------------------------------------
diff --git a/Working_Examples/3432/CH3/EX3.11/Ex3_11.sce b/Working_Examples/3432/CH3/EX3.11/Ex3_11.sce new file mode 100755 index 0000000..a033bf8 --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.11/Ex3_11.sce @@ -0,0 +1,16 @@ +//Example 3.11
+//Computing DC gain of the system.
+
+clear;
+clc;
+//------------------------------------------------------------------
+//Transfer Function
+s=poly(0,'s');
+num=3*(s+2);
+den=(s^2+2*s+10);
+Ys=syslin('c',num/den);
+
+//The DC gain of the system Y(s) as s-->0 is
+DC_Gain=horner(Ys,0)
+disp(DC_Gain,"The DC gain of the system is:")
+//------------------------------------------------------------------
diff --git a/Working_Examples/3432/CH3/EX3.14/Ex3_14.sce b/Working_Examples/3432/CH3/EX3.14/Ex3_14.sce new file mode 100755 index 0000000..c1ab833 --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.14/Ex3_14.sce @@ -0,0 +1,23 @@ +//Example 3.14
+//Partial fraction expansion for distinct real roots
+clear;
+clc;
+//------------------------------------------------------------------
+// Transfer function
+s=%s;
+num=2;
+p1=(s+1);
+p2=(s+2);
+p3=(s+4);
+sys=syslin('c',num/(p1*p2*p3))
+
+//Partial fraction expansion is: sys= r1/p1 + r2/p2 + r3/p3
+//residue calculation
+r1=residu(num,p1,(p2*p3))
+r2=residu(num,p2,(p1*p3))
+r3=residu(num,p3,(p1*p2))
+
+disp([r1 r2 r3]',"Residues of the poles p1, p2 and p3 are")
+disp([roots(p1), roots(p2), roots(p3)]',"Poles p1, p2 and p3 are at")
+disp('k=[]')
+//------------------------------------------------------------------
diff --git a/Working_Examples/3432/CH3/EX3.15/Ex3_15.sce b/Working_Examples/3432/CH3/EX3.15/Ex3_15.sce new file mode 100755 index 0000000..ad95139 --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.15/Ex3_15.sce @@ -0,0 +1,23 @@ +//Example 3.15 Cruise Control Transfer Function.
+//Coefficients of numerator and denominator of the transfer function
+
+clear;
+clc;
+//------------------------------------------------------------------
+// Transfer function coefficients
+num=[0.001 0];
+den=[0 0.05 1];
+
+// Transfer function
+Ns=poly(num,'s','coeff');
+Ds=poly(den,'s','coeff');
+sys=syslin('c',Ns/Ds);
+
+//gain (K) pole (P) and zeros (Z) of the system
+temp=polfact(Ns);
+Z=roots(Ns); //locations of zeros
+P=roots(Ds); //locations of poles
+K=temp(1); //first entry is always gain
+disp( K,"Gain", P, "Poles",Z,"Zeros",)
+
+//------------------------------------------------------------------
diff --git a/Working_Examples/3432/CH3/EX3.16/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH3/EX3.16/DEPENDENCIES/fig_settings.sci new file mode 100755 index 0000000..5d5e7d4 --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.16/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.16/Ex3_16.sce b/Working_Examples/3432/CH3/EX3.16/Ex3_16.sce new file mode 100755 index 0000000..84c0062 --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.16/Ex3_16.sce @@ -0,0 +1,32 @@ +//Example 3.16 DC Motor Transfer Function.
+
+xdel(winsid())//close all graphics Windows
+clear;
+clc;
+//------------------------------------------------------------------
+//Coefficients of numerator and denominator of the transfer function
+numb=[100];
+denb=[0 101 10.1 1];
+
+// Transfer function
+Ns=poly(numb,'s','coeff');
+Ds=poly(denb,'s','coeff');
+sysb=syslin('c',Ns/Ds);
+
+//gain (K) pole (P) and zeros (Z) of the system
+temp=polfact(Ns);
+Z=roots(Ns); //locations of zeros
+P=roots(Ds); //locations of poles
+K=temp(1); //first entry is always gain
+disp( K,"Gain", P, "Poles",Z,"Zeros",)
+
+//Transient response of DC Motor (consider velocity as output)
+s=%s;
+t=linspace(0,5,501);
+y=csim('step',t,sysb*s)
+plot(t,y)
+exec .\fig_settings.sci; //custom script for setting figure properties
+title('Transient response of DC Motor','fontsize',3)
+xlabel('$Time\,\, t(sec.)$','fontsize',3)
+ylabel('$\omega\,\,(rad/sec)$','fontsize',3)
+//------------------------------------------------------------------
diff --git a/Working_Examples/3432/CH3/EX3.16/Ex3_16_f0.pdf b/Working_Examples/3432/CH3/EX3.16/Ex3_16_f0.pdf Binary files differnew file mode 100755 index 0000000..13ab471 --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.16/Ex3_16_f0.pdf diff --git a/Working_Examples/3432/CH3/EX3.17/Ex3_17.sce b/Working_Examples/3432/CH3/EX3.17/Ex3_17.sce new file mode 100755 index 0000000..fe149dd --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.17/Ex3_17.sce @@ -0,0 +1,21 @@ +//Example 3.17 Transformations
+
+clear;
+clc;
+//-------------------------------------------------------------------
+//Coefficients of numerator and denominator of the transfer function
+numG=[9 3];
+denG=[25 6 1];
+
+// Transfer function
+Ns=poly(numG,'s','coeff');
+Ds=poly(denG,'s','coeff');
+sysG=syslin('c',Ns/Ds);
+
+//gain (K) pole (P) and zeros (Z) of the system
+temp=polfact(Ns);
+Z=roots(Ns); //locations of zeros
+P=roots(Ds); //locations of poles
+K=temp(1); //first entry is always gain
+disp( K,"Gain", P, "Poles",Z,"Zeros",)
+//------------------------------------------------------------------
diff --git a/Working_Examples/3432/CH3/EX3.18/Ex3_18.sce b/Working_Examples/3432/CH3/EX3.18/Ex3_18.sce new file mode 100755 index 0000000..311eb6f --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.18/Ex3_18.sce @@ -0,0 +1,71 @@ +//Example 3.18 Satellite Transfer Function
+
+xdel(winsid())//close all graphics Windows
+clear;
+clc;
+//------------------------------------------------------------------
+//(a)
+//Given
+d=1 //meters
+I=5000 //Kg-meter^2
+
+//Coefficients of numerator and denominator of the transfer function
+// of satellite
+numG=[d/I 0];
+denG=[0 0 1];
+
+// Transfer function
+Ns=poly(numG,'s','coeff');
+Ds=poly(denG,'s','coeff');
+sysG=syslin('c',Ns/Ds);
+t=0:0.01:10;
+[i j]=size(t);
+
+//------------------------------------------------------------------
+//(b)
+// Thrust input after 5 sec.
+u=zeros(1,j);
+w=find(t>=5 & t<=5+0.1);
+u(w)=25;
+plot(t,u);
+exec .\fig_settings.sci; //custom script for setting figure properties
+title("Transient response of the satellite...
+ (a) Thrust input",'fontsize',3);
+xlabel('Time t (sec.)','fontsize',2)
+ylabel('Fc','fontsize',2)
+
+//Transient response of the satellite to the thrust input as a pulse
+sysd=dscr(sysG,0.01); //sample data system model
+y=flts(u,sysd); //impulse response
+figure, plot(t,y*180/%pi);
+exec .\fig_settings.sci; //custom script for setting figure properties
+title("Transient response of the satellite(double-pulse)...
+ (b) satellite attitude",'fontsize',3);
+xlabel('Time t (sec.)','fontsize',2)
+ylabel('$\theta(deg)$','fontsize',2)
+//------------------------------------------------------------------
+// Thrust input double-pulse.
+u=zeros(1,j);
+w1=find(t>=5 & t<=5+0.1);
+u(w1)=25;
+w2=find(t>=6.1 & t<=6.1+0.1);
+u(w2)=-25;
+figure,
+plot(t,u);
+exec .\fig_settings.sci; //custom script for setting figure properties
+title("Transient response of the satellite (double-pulse)...
+ (a) Thrust input",'fontsize',3);
+xlabel('Time t (sec.)','fontsize',2)
+ylabel('Fc','fontsize',2)
+
+//Transient response of the satellite to the thrust input as a pulse
+sysd=dscr(sysG,0.01); //sample data system model
+y=flts(u,sysd); //impulse response
+figure, plot(t,y*180/%pi);
+exec .\fig_settings.sci; //custom script for setting figure properties
+title("Transient response of the satellite(double-pulse)...
+ (b) satellite attitude",'fontsize',3);
+xlabel('Time t (sec.)','fontsize',2)
+ylabel('$\theta(deg)$','fontsize',2)
+
+//------------------------------------------------------------------
diff --git a/Working_Examples/3432/CH3/EX3.18/Ex3_18_f1.pdf b/Working_Examples/3432/CH3/EX3.18/Ex3_18_f1.pdf Binary files differnew file mode 100755 index 0000000..b79b5d1 --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.18/Ex3_18_f1.pdf diff --git a/Working_Examples/3432/CH3/EX3.18/Ex3_18_f3.pdf b/Working_Examples/3432/CH3/EX3.18/Ex3_18_f3.pdf Binary files differnew file mode 100755 index 0000000..ef8fa00 --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.18/Ex3_18_f3.pdf diff --git a/Working_Examples/3432/CH3/EX3.21/Ex3_21.sce b/Working_Examples/3432/CH3/EX3.21/Ex3_21.sce new file mode 100755 index 0000000..57a2481 --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.21/Ex3_21.sce @@ -0,0 +1,42 @@ +//Example 3.21
+//Series, Parallel and Feedback connections of TF blocks
+//to get effective TF.
+
+clear;
+clc;
+//------------------------------------------------------------------
+//Transfer function block G1
+num1=[2];
+den1=[1];
+Ns=poly(num1,'s','coeff');
+Ds=poly(den1,'s','coeff');
+sysG1=syslin('c',Ns/Ds);
+
+//Transfer function block G2
+num2=[4];
+den2=[0 1];
+Ns=poly(num2,'s','coeff');
+Ds=poly(den2,'s','coeff');
+sysG2=syslin('c',Ns/Ds);
+
+//Transfer function block G4
+num4=[1];
+den4=[0 1];
+Ns=poly(num4,'s','coeff');
+Ds=poly(den4,'s','coeff');
+sysG4=syslin('c',Ns/Ds);
+
+//Transfer function block G6
+num6=[1];
+den6=[1];
+Ns=poly(num6,'s','coeff');
+Ds=poly(den6,'s','coeff');
+sysG6=syslin('c',Ns/Ds);
+
+//Effective transfer function
+// (+) operator for paralle connection,
+// (*) operator for series connection
+// (/.)operator for feedback connection
+sysG=(sysG1 + sysG2) * sysG4 /. sysG6
+disp(sysG, "The effective transfer function is")
+//------------------------------------------------------------------
diff --git a/Working_Examples/3432/CH3/EX3.22/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH3/EX3.22/DEPENDENCIES/fig_settings.sci new file mode 100755 index 0000000..5d5e7d4 --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.22/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.22/Ex3_22.sce b/Working_Examples/3432/CH3/EX3.22/Ex3_22.sce new file mode 100755 index 0000000..b49701f --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.22/Ex3_22.sce @@ -0,0 +1,47 @@ +//Example 3.22 Response Versus Pole Locations, Real Roots
+
+xdel(winsid())//close all graphics Windows
+clear;
+clc;
+//------------------------------------------------------------------
+//Transfer function
+numH=[1 2];
+denH=[2 3 1];
+Ns=poly(numH,'s','coeff');
+Ds=poly(denH,'s','coeff');
+sysH=syslin('c',Ns/Ds);
+
+//Pole-zero locations
+//Partial fraction method to see the effect of sperated poles
+temp=polfact(Ds);
+p1s=temp(2);
+p2s=temp(3);
+
+//residues at poles
+r1=residu(Ns,p1s,p2s);
+r2=residu(Ns,p2s,p1s);
+
+//Note that - H1(s)+H2(s)=H(s)
+H1s=syslin('c',r1/p1s);
+H2s=syslin('c',r2/p2s);
+
+//impulse response of the H1(s), H2(s) and H(s)
+t=0:0.02:10;
+h1=csim('impuls',t,H1s);
+h2=csim('impuls',t,H2s);
+h=csim('impuls',t,sysH);
+figure,
+plot(t,h1,'r--',t,h2,'m-.', t, h, 'b')
+plot(t,h2,'m-.')
+plot(t,h)
+
+exec .\fig_settings.sci; //custom script for setting figure properties
+title(['impulse response of the system and subsystems with...
+ independent poles.';'(h1(t) is faster than h2(t))'],'fontsize',3)
+xlabel('Time t (sec.)','fontsize',2)
+ylabel('h(t), h1(t), h2(t)','fontsize',2)
+h=legend('h1(t) with pole at -2','h2(t) with pole at -1'...
+,'h(t)=h1(t)+h2(t)')
+h.legend_location = "in_upper_right"
+h.fill_mode='off'
+//------------------------------------------------------------------
diff --git a/Working_Examples/3432/CH3/EX3.22/Ex3_22_f0.pdf b/Working_Examples/3432/CH3/EX3.22/Ex3_22_f0.pdf Binary files differnew file mode 100755 index 0000000..52d43ff --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.22/Ex3_22_f0.pdf diff --git a/Working_Examples/3432/CH3/EX3.23/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH3/EX3.23/DEPENDENCIES/fig_settings.sci new file mode 100755 index 0000000..5d5e7d4 --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.23/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.23/Ex3_23.sce b/Working_Examples/3432/CH3/EX3.23/Ex3_23.sce new file mode 100755 index 0000000..613d47c --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.23/Ex3_23.sce @@ -0,0 +1,49 @@ +//Example 3.23 Oscillatory Time Response
+
+xdel(winsid())//close all graphics Windows
+clear;
+clc;
+//------------------------------------------------------------------
+//Transfer function of second order underdamped system
+numH=[1 2];
+denH=[5 2 1];
+Ns=poly(numH,'s','coeff');
+Ds=poly(denH,'s','coeff');
+sysH=syslin('c',Ns/Ds);
+
+//damping factor (xi) and natural frequency (wn)
+[wn xi]=damp(sysH);
+wn=wn(1);
+xi=xi(1);
+sigma=xi*wn;
+wd=wn*sqrt(1-xi^2);
+
+//denominator in sigma-wn form H(s)=H1(s)+H2(s)
+s=%s;
+p=(s+sigma)^2+wd^2
+temp=polfact(Ns);
+k=temp(1),zr=temp(2);
+h1=(s+sigma)/p;
+h2=-((s+sigma)-temp(2))*wd/p;
+H1s=syslin('c',k*h1);
+H2s=syslin('c',k*h2/wd);
+
+// responses with exponential envelope
+Env=syslin('c',k/(s+sigma));
+t=0:0.02:10;
+//impulse response
+ht=csim('impuls',t,sysH);
+envt=csim('impuls',t,Env);
+envt_neg=csim('impuls',t,-Env);
+
+plot(t,ht)
+plot(t,envt,'r--')
+plot(t,envt_neg,'r--')
+exec .\fig_settings.sci; //custom script for setting figure properties
+title('Impulse response of the underdamped system','fontsize',3)
+xlabel('Time t (sec.)','fontsize',2)
+ylabel('h(t)','fontsize',2)
+xset("font",1,2)
+xstring(1,0.75,"$e^{-\sigma t}$",0,0)
+xstring(1,-0.85,"$-e^{-\sigma t}$",0,0)
+//------------------------------------------------------------------
diff --git a/Working_Examples/3432/CH3/EX3.23/Ex3_23_f0.pdf b/Working_Examples/3432/CH3/EX3.23/Ex3_23_f0.pdf Binary files differnew file mode 100755 index 0000000..a3886b8 --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.23/Ex3_23_f0.pdf diff --git a/Working_Examples/3432/CH3/EX3.25/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH3/EX3.25/DEPENDENCIES/fig_settings.sci new file mode 100755 index 0000000..5d5e7d4 --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.25/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.25/Ex3_25.sce b/Working_Examples/3432/CH3/EX3.25/Ex3_25.sce new file mode 100755 index 0000000..3377471 --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.25/Ex3_25.sce @@ -0,0 +1,52 @@ +//Example 3.25 Aircraft Response
+xdel(winsid())//close all graphics Windows
+clear;
+clc;
+//------------------------------------------------------------------
+//(a)impulse response of aircraft
+
+//Transfer function of aircraft
+numG=[-6 1];
+denG=[0 13 4 1];
+Ns=30*poly(numG,'s','coeff');
+Ds=poly(denG,'s','coeff');
+u=-1 //impulsive elevator input of 1 degree
+sysG=syslin('c',u*Ns/Ds);
+
+//impulse response
+t=0:0.02:10;
+gt=csim('impuls',t,sysG);
+plot(t,gt)
+exec .\fig_settings.sci; //custom script for setting figure properties
+title('Response of an airplanes altitude to an impulsive elevator input','fontsize',3)
+xlabel('Time (sec.)','fontsize',2)
+ylabel('Altitude (ft)','fontsize',2)
+
+//final value theorem, lim s-->0 in s*G(s)
+s=%s;
+gt_final=horner(s*sysG,0)
+disp(gt_final,"The final value of the output altitude is:")
+//------------------------------------------------------------------
+//(b)response specifications
+
+//damping factor (xi) and natural frequency (wn)
+[wn xi]=damp(sysG);
+wn=wn(2);//natural frequency (wn)
+xi=xi(2);//damping factor
+disp(wn,xi,"Damping factor and natural frequency (rad)...
+ of the response are:")
+
+tr=1.8/wn; //rise time
+disp(tr,"Rise time (sec) of the response is:")
+
+sigma=xi*wn
+ts=4.6/sigma; //settling time
+disp(ts,"Settling time (sec) of the response is:")
+
+Mp=exp(-xi*%pi/sqrt(1-xi^2))
+wd=wn*sqrt(1-xi^2);
+tp=%pi/wd;
+disp(tp, Mp,"Overshoot and time of overshoot (sec)...
+ in the response are:")
+
+//------------------------------------------------------------------
diff --git a/Working_Examples/3432/CH3/EX3.25/Ex3_25_f0.pdf b/Working_Examples/3432/CH3/EX3.25/Ex3_25_f0.pdf Binary files differnew file mode 100755 index 0000000..0ea8ea8 --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.25/Ex3_25_f0.pdf diff --git a/Working_Examples/3432/CH3/EX3.29/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH3/EX3.29/DEPENDENCIES/fig_settings.sci new file mode 100755 index 0000000..5d5e7d4 --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.29/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.29/Ex3_29.sce b/Working_Examples/3432/CH3/EX3.29/Ex3_29.sce new file mode 100755 index 0000000..2f18710 --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.29/Ex3_29.sce @@ -0,0 +1,40 @@ +//Example 3.29
+//Stability versus parameter range
+
+xdel(winsid())//close all graphics Windows
+clear;
+clc;
+//------------------------------------------------------------------
+//Stability versus parameter range
+
+numT=[-1];//zeros
+denT=[1 0 -6];//poles
+Ns=poly(numT,'s','roots');
+Ds=poly(denT,'s','roots');
+Gfs=syslin('c',Ns/Ds); //forward transfer function block
+
+num=[1];
+den=[1 0];
+Ns=poly(num,'s','coeff');
+Ds=poly(den,'s','coeff');
+Hs=syslin('c',Ns/Ds); //feedback transfer function block
+
+//check the step responses with the forward path gain K=7.5, 13, 25
+t=0:0.02:12;
+i=1;
+
+for K=[7.5, 13, 25]
+ sysT= (K * Gfs) /. Hs;
+ yt(i,:)=csim('step',t,sysT);
+ i=i+1;
+end
+//Step response
+plot(t',yt')
+exec .\fig_settings.sci; //custom script for setting figure properties
+title("Transient response for different values of K",'fontsize',3);
+xlabel('Time t (sec.)','fontsize',2)
+ylabel('y(t)','fontsize',2)
+h=legend('K=7.5','K=13', 'K=25')
+h.legend_location = "in_upper_right"
+h.fill_mode='off'
+//------------------------------------------------------------------
diff --git a/Working_Examples/3432/CH3/EX3.29/Ex3_29_f0.pdf b/Working_Examples/3432/CH3/EX3.29/Ex3_29_f0.pdf Binary files differnew file mode 100755 index 0000000..1dcf459 --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.29/Ex3_29_f0.pdf diff --git a/Working_Examples/3432/CH3/EX3.30/DEPENDENCIES/fig_settings.sci b/Working_Examples/3432/CH3/EX3.30/DEPENDENCIES/fig_settings.sci new file mode 100755 index 0000000..5d5e7d4 --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.30/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.30/Ex3_30.sce b/Working_Examples/3432/CH3/EX3.30/Ex3_30.sce new file mode 100755 index 0000000..5a06bc3 --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.30/Ex3_30.sce @@ -0,0 +1,46 @@ +//Example 3.30
+//Stability versus two parameter ranges
+xdel(winsid())//close all graphics Windows
+clear;
+clc;
+//------------------------------------------------------------------
+//Stability versus parameter ranges
+
+num=[1 0];//zeros
+den=[-1 -2];//poles
+Ns=poly(num,'s','coeff');
+Ds=poly(den,'s','roots');
+Gfs=syslin('c',Ns/Ds); //forward transfer function block
+
+num=[1];
+den=[1 0];
+Ns=poly(num,'s','coeff');
+Ds=poly(den,'s','coeff');
+Hs=syslin('c',Ns/Ds); //feedback transfer function block
+
+//check the step responses with the forward, path gain K=7.5, 13, 25
+t=0:0.02:12;
+i=1;
+num=[5 10;1 1;0 1];
+
+for i=1:3
+ den=[0 1];
+ Ns=poly(num(i,:),'s','coeff');
+ Ds=poly(den,'s','coeff');
+ Gcs=syslin('c',Ns/Ds); //Controller transfer function block
+ sysT= Gcs * Gfs /. Hs;
+ yt(i,:)=csim('step',t,sysT);
+ i=i+1;
+end
+
+//Transient response for different values of K and Ki
+plot(t',yt')
+exec .\fig_settings.sci; //custom script for setting figure properties
+title("Transient response for the system",'fontsize',3);
+xlabel('Time t (sec.)','fontsize',2)
+ylabel('y(t)','fontsize',2)
+xset("font",1,1)
+xstring(1.4,1.05,'$K=10,K_I=5$');
+xstring(3.3,0.8,'$K=1,K_I=1$');
+xstring(5.5,0.35,'$K=1,K_I=0$')
+//------------------------------------------------------------------
diff --git a/Working_Examples/3432/CH3/EX3.30/Ex3_30_f0.pdf b/Working_Examples/3432/CH3/EX3.30/Ex3_30_f0.pdf Binary files differnew file mode 100755 index 0000000..f056d31 --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.30/Ex3_30_f0.pdf 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 Binary files differnew file mode 100755 index 0000000..8910b81 --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.4/Ex3_4_f0.pdf diff --git a/Working_Examples/3432/CH3/EX3.4/Ex3_4_f1.pdf b/Working_Examples/3432/CH3/EX3.4/Ex3_4_f1.pdf Binary files differnew file mode 100755 index 0000000..1a5b20a --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.4/Ex3_4_f1.pdf diff --git a/Working_Examples/3432/CH3/EX3.8/Ex3_8.sce b/Working_Examples/3432/CH3/EX3.8/Ex3_8.sce new file mode 100755 index 0000000..d0fe556 --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.8/Ex3_8.sce @@ -0,0 +1,26 @@ +//Example 3.8
+//Partial fraction expansion for distinct real roots.
+
+clear;
+clc;
+//------------------------------------------------------------------
+//Partial fraction expansion for distinct real roots
+// Transfer function
+s=%s;
+num=(s+2)*(s+4)
+p1=s;
+p2=(s+1);
+p3=(s+3);
+sys=syslin('c',num/(p1*p2*p3))
+//------------------------------------------------------------------
+//Partial fraction expansion is: sys= r1/p1 + r2/p2 + r3/p3
+//residue calculation
+r1=residu(num,p1,(p2*p3))
+r2=residu(num,p2,(p1*p3))
+r3=residu(num,p3,(p1*p2))
+
+disp([r1 r2 r3]',"Residues of the poles p1, p2 and p3 are")
+disp([roots(p1), roots(p2), roots(p3)]',"Poles p1, p2 and p3 are at")
+disp('k=[]')
+
+//------------------------------------------------------------------
diff --git a/Working_Examples/3432/CH3/EX3.9/Ex3_9.sce b/Working_Examples/3432/CH3/EX3.9/Ex3_9.sce new file mode 100755 index 0000000..b061c05 --- /dev/null +++ b/Working_Examples/3432/CH3/EX3.9/Ex3_9.sce @@ -0,0 +1,22 @@ +//Example 3.9
+//Computing final value (use of final value theorem).
+
+clear;
+clc;
+
+//------------------------------------------------------------------
+
+//Computing final value (use of final value theorem)
+// Output of the system
+s=poly(0,'s');
+num=3*(s+2);
+den=s*(s^2+2*s+10);
+Ys=syslin('c',num/den);
+
+
+//final value theorem, lim s-->0 in s*Y(s)
+
+Y_final=horner(s*Ys,0)
+disp(Y_final,"The final value of the output y is:")
+
+//------------------------------------------------------------------
|