42
INDEX LA B NO . OBJECT NAME PAGE NO. 1 Introduction to Matlab. 1 - 3 2 To solve the block diagram for C/R. 4 - 5 3 To solve the block diagram for C/R and confirm with MASON GAIN FORMULA. 6 - 7 4 Implementation of Series, Parallel and Feedback command, to solve the block diagram for C/R. 8 - 10 5 To solve the block diagram for X1(s)/F(s). 11 - 12 6 To plot the graph of Sin, Cos and Tan. 13 -15 7 To find the following with the help of canonical diagram, (a) Transfer function to state space model. (b) and (c)State space model to transfer function. (d) Complete solution of state space model. 16 - 19 8 (a) Find the residues of G(s)=5/s+2, (i) R(s) = unit step(1/s) (ii) R(s) = unit ramp(1/s^2) (b) Find c(t), (i) R(s) = unit step(1/s) (ii) R(s) = unit ramp(1/s^2) 20 - 22 9 Find step response, (i) R(s) = unit step(1/s) (ii) 23 - 24 0

Lab Manual of Lcs

Embed Size (px)

Citation preview

Page 1: Lab Manual of Lcs

I N D E X

LABNO

.

OBJECT NAME PAGENO.

1 Introduction to Matlab. 1 - 3

2 To solve the block diagram for C/R. 4 - 5

3 To solve the block diagram for C/R and confirm with MASON GAIN FORMULA. 6 - 7

4 Implementation of Series, Parallel and Feedback command, to solve the block diagram for C/R. 8 - 10

5 To solve the block diagram for X1(s)/F(s). 11 - 12

6 To plot the graph of Sin, Cos and Tan. 13 -15

7 To find the following with the help of canonical diagram,(a) Transfer function to state space model.(b) and (c)State space model to transfer function.(d) Complete solution of state space model.

16 - 19

8 (a) Find the residues of G(s)=5/s+2,(i) R(s) = unit step(1/s) (ii) R(s) = unit ramp(1/s^2)(b) Find c(t),(i) R(s) = unit step(1/s) (ii) R(s) = unit ramp(1/s^2)

20 - 22

9 Find step response,(i) R(s) = unit step(1/s) (ii) R(s) = unit ramp(1/s^2)

23 - 24

10 To find the step response of second order system for different values of zeta.

25 - 26

11 The block diagram of a position control servo mechanism is given below, find step response, maximum peak amplitude, steady state value, peak time and settling time.

27 - 29

0

Page 2: Lab Manual of Lcs

12 Sketch the root locus using rlocus command. 30 - 32

LABORTARY EXERCISE # 1

OBJECTIVE:

Introduction to Matlab.

THEORY:

Matlab is one of the fastest and most enjoyable ways to solve problems numerically. The computational problems arising in most undergraduate courses can be solved much more quickly with Matlab, than with the standard programming languages (Fortran, C, Java, etc.). It is particularly easy to generate some results, draw graphs to look at the interesting features, and then explore the problem further. By minimizing human time, Matlab is particularly useful in the initial investigation of real problems; even though they may eventually have to be solved using more computationally efficient ways on super computers.

COMMANDS:

PLOT(X,Y), PLOT(X,Y) plots vector Y versus vector X. If X or Y is a matrix, then the vector is plotted versus the rows or columns of the matrix, whichever line up. If X is a scalar and Y is a vector, disconnected line objects are created and plotted as discrete points vertically at X. PLOT(Y) plots the columns of Y versus their index. If Y is complex, PLOT(Y) is equivalent to PLOT(real(Y),imag(Y)). In all other uses of PLOT, the imaginary part is ignored. Various line types, plot symbols and colors may be obtained with PLOT(X,Y,S) where S is a character string made from one element from any or all the following 3 columns: b blue . point - solid g green o circle : dotted r red x x-mark -. dashdot c cyan + plus -- dashed

1

Page 3: Lab Manual of Lcs

m magenta * star (none) no line y yellow s square k black d diamond v triangle (down) ^ triangle (up) < triangle (left) > triangle (right) p pentagram h hexagramFor example, PLOT(X,Y,'c+:') plots a cyan dotted line with a plus at each data point; PLOT(X,Y,'bd') plots blue diamond at each data point but does not draw any line. XLABEL,XLABEL('text') adds text beside the X-axis on the current axis.

YLABEL,YLABEL('text') adds text beside the Y-axis on the current axis.

TITLE,TITLE('text') adds text at the top of the current axis.

GRID,GRID ON adds major grid lines to the current axes.GRID OFF removes major and minor grid lines from the current axes.

DET, Determinant.DET(X) is the determinant of the square matrix X.

INV,Matrix inverse.INV(X) is the inverse of the square matrix X.A warning message is printed if X is badly scaled or nearly singular.

PROGRAM CODING:

x=1:1:10y=x.^2plot(x,y,'ro-')xlabel('linear')ylabel('squared')title('graph between linear and squared terms')gtext('x^2')grid

2

Page 4: Lab Manual of Lcs

RESULT:

x = 1 2 3 4 5 6 7 8 9 10

y = 1 4 9 16 25 36 49 64 81 100

ASSIGNMENT: Related Exercise problems.

3

Page 5: Lab Manual of Lcs

LABORTARY EXERCISE # 2

OBJECTIVE:

To solve the block diagram for C/R.

(a) R + E C

-

(b)

R + E1 B + + E2 C

-

THEORY:

(a)

C=GE ------- Equ1 E=R-HC ------- Equ2

Put equ2 in equ1,C=G(R-HC)C=GR-GHCC+GHC=GRC(1+GH)=GR

4

G

H

G1 G2

G3

G4

Page 6: Lab Manual of Lcs

C/R=G/1+GH

(b)

E1=R-BB=G1*E1E2=G2/B+B*G3C=G4*E2

C/R=(G1/1+G1)*(G2+G3)*G4 = ((G1G2G4)+(G1G3G4))/(1+G1)

COMMANDS:

SOLVE,With the help of solve command we can solve symbolic equations.

e.g

syms x y zeq1 = 'x - 2*y + z = 0';eq2 = '2*y - 8*z = 8';eq3 = '-4*x + 5*y + 9*z = -9';[x,y,z] = solve(eq1, eq2, eq3)

SYMS,Create one or more symbolic variables

e.g

syms x y z

PROGRAM CODING:

syms E1 R B G1 E2 G2 G3 G4 E2 C ans=solve('E1=R-B','B=G1*E1','E2=G2*B+B*G3','C=G4*E2',C,E1,E2,B)ans.C

RESULT:

ans =G4*G1*(G2+G3)/(1+G1)

ASSIGNMENT: Related Exercise problems.

5

Page 7: Lab Manual of Lcs

LABORTARY EXERCISE # 3

OBJECTIVE:

To solve the block diagram for C/R and confirm with MASON GAIN FORMULA.

(a)

3 1 A 10 B -2 4

- 4

(b)G4

R 1 E1 G1 E2 G2 E3 G3 E4 1 C

-H1 -H2

-H3

THEORY:

(a)A’/3=M1*∆1/∆M1=1, ∆1=1, ∆=1-(-40)=41A’=3/41

A’’/4= M1*∆1/∆M1=8, ∆1=1, ∆=1-(-40)=41

6

Page 8: Lab Manual of Lcs

A’’=32/41A=A’+A’’=32/41+3/41=35/41

B’/3=M1*∆1/∆M1=10, ∆1=1, ∆=1-(-40)=41B’=30/41

B’’/4= M1*∆1/∆M1=-2, ∆1=1, ∆=1-(-40)=41B’’=-8/41B=B’+B’’=30/41-8/41=22/41

(b)C/R= ((M1*∆1)+ (M2*∆2))/∆M1=G1*G2*G3, M2=G1*G4∆1=1, ∆2=1+G3*H2

∆=1-(-G1*H1-G3*H2-G1*G2*G3*H3)+(G1*G3*H1*H2) =1+G1*H1+G3*H2+G1*G2*G3*H3+G1*G3*H1*H2

C\R= G1*G2*G3+ G1*G4+ G1*G4*G3*H2

COMMANDS: Two commands are used solve and syms which are already discussed in lab 2.

PROGRAM CODING:

(a)syms A Bequ1=3-B*4-Aequ2=10*A-8-Bs=solve(equ1,equ2,A,B)s.As.B

(b)syms R C E1 E2 E3 E4 H1 H2 H3 G1 G2 G3 G4 equ1=R-E4*H3-E2*H1-E1equ2=G1*E1-E2equ3=G2*E2-E4*H2-E3equ4=G3*E3-E4equ5=E4+G4*E2-Cs=solve(equ1,equ2,equ3,equ4,equ5,C,E1,E2,E3,E4)

7

Page 9: Lab Manual of Lcs

s.C/R

RESULT:

(a)ans =35/41 ans =22/41

(b)ans =G1*(G3*G2+G4*G3*H2+G4)/(G3*H2+G2*G1*G3*H3+G1*H1*G3*H2+G1*H1+1)

ASSIGNMENT: Related Exercise problems.LABORTARY EXERCISE # 4

OBJECTIVE:

Implementation of Series, Parallel and Feedback command, to solve the block diagram for C/R.

+R + + C

-

THEORY:

G1(s)=1/(s+2)G2(s)=(s+2)/(s^2+3)G3(s)=5H(s)=1/s

Above block diagram have one parallel, one series and one feedback connection.

G2 and G3 are in parallel,G2+G3 = ((s+2)/(s^2+3)) + 5 = (5s^2+s+17)/(s^2+3)

8

G1 G2

G3

H

Page 10: Lab Manual of Lcs

G1 and H are in feedback,= (1/(s+2)/(1+(1/(s+2))(1/s))= (1/(s+2)/(1+(1/(s^2+2s)))= (1/(s+2)*((s^2+2s)/(s^2+2s+1))= s/(s^2+2s+1)

While these two finally are in series.C(s)/R(s)=(5s^3+s^2+17s)/( s^4+2s^3+4s^2+6s+3)

COMMANDS:

You can implement ‘s’ domain variable with the help of following two commands:

By s= tf('s'),s= tf('s') specifies the transfer function H(s) = s (Laplace variable).

You can then specify transfer functions directly as rational expressions in S or Z, e.g., s = tf('s'); H = (s+1)/(s^2+3*s+1)

By tf command,Typing, h = tf(num,den)where num and den are row vectors listing the coefficients of the polynomials and , respectively, when these polynomials are ordered in descending powers of s. The resulting variable h is a TF object containing the numerator and denominator data.

For example, you can create the transfer function by typingh = tf([1 0],[1 2 10])

MATLAB responds withTransfer function: s--------------s^2 + 2 s + 10

Series command,Series interconnection of the two LTI models,

SYS = SERIES(SYS1,SYS2,OUTPUTS1,INPUTS2) connects two LTI models SYS1 and SYS2 in series such that the outputs of SYS1 specified by OUTPUTS1 are connected to the inputs of SYS2 specified by INPUTS2. The vectors OUTPUTS1 and INPUTS2 contain indices into the outputs and inputs of SYS1 and SYS2, respectively.

9

Page 11: Lab Manual of Lcs

If OUTPUTS1 and INPUTS2 are omitted, SERIES connects SYS1 and SYS2 in cascade and returns SYS = SYS2 * SYS1 Parallel command, Parallel interconnection of two LTI models. SYS = PARALLEL(SYS1,SYS2,IN1,IN2,OUT1,OUT2) connects the two LTI models SYS1 and SYS2 in parallel such that the inputs specified by IN1 and IN2 are connected and the outputs specified by OUT1 and OUT2 are summed . If IN1,IN2,OUT1,OUT2 are jointly omitted, PARALLEL forms the standard parallel interconnection of SYS1 and SYS2 and returns SYS = SYS2 + SYS1 Feedback command,Feedback interconnection of two LTI models. SYS = FEEDBACK(SYS1,SYS2) computes an LTI model SYS for the closed-loop feedback system Negative feedback is assumed and the resulting system SYS maps u to y. To apply positive feedback, use the syntax SYS = FEEDBACK(SYS1,SYS2,+1). SYS = FEEDBACK(SYS1,SYS2,FEEDIN,FEEDOUT,SIGN) builds the more general feedback interconnection:

PROGRAM CODING:

(a)

s=tf('s')G1=1/(s+2);G2=(s+2)/(s^2+3);G3=5;H=1/s;p1=parallel(G2,G3);p2=feedback(G1,H,-1);p3=series(p1,p2)

(b)n1=[0 1];d1=[1 2];G1=tf(n1,d1);

10

Page 12: Lab Manual of Lcs

n2=[0 1 2];d2=[1 0 3];G2=tf(n2,d2);n3=[5];d3=[1];G3=tf(n3,d3);n4=[0 1];d4=[1 0];H=tf(n4,d4);p1=parallel(G2,G3);p2=feedback(G1,H,-1);p3=series(p1,p2)

RESULT:

(Output is same for both of program only way of coding is change)

Transfer function: 5 s^3 + s^2 + 17 s-----------------------------s^4 + 2 s^3 + 4 s^2 + 6 s + 3

ASSIGNMENT: Related Exercise problems.

LABORTARY EXERCISE # 5

OBJECTIVE:

To solve the block diagram for X1(s)/F(s).

11

x2(t)

M2

M1

x1(t)

f(t)

K2 B2

B1K1

Page 13: Lab Manual of Lcs

THEORY:

Forces = ma

At x1(t),M1*s^2*X1(s) = F(s) - K1*X1(s) + K1*X2(s) - B1*s*X1(s) + B1*s*X2(s)

X1(s) [ M1*s^2 + K1 + B1*s ] - X2(s) [K1+B1*s] = F(s) --------- equ. (1)

At x2(t),M2*s^2*X2(s) = - K2*X2(s) + K1*X1(s) - K1*X2(s) – B2*s*X2(s)+ B1*s*X1(s) - B1*s*X2(s)

X2(s) [ M2*s^2 + K1 + K2 + B1*s + B2*s ] – X1(s) [K1+B1*s] = 0--------- equ. (2)

∆ =

= (M1*s^2 + K1 + B1*s)(M2*s^2 + K1 + K2 + B1*s + B2*s) + (K1+B1*s)(-K1-B1*s)

= M1*M2*s^4 + M1*s^2*K1 + M1*s^2*K2 + M1*s^2* B1*s + M1*s^2* B2*s + M2*s^2* K1 + K1*K1 + K2* K1 + B1*s* K1 + B2*s* K1 + M2*s^3*B1 + K1* B1*s + K2* B1*s + B1^2*s^2 + B2*B1*s^2- K1*K1- B1*s* K1 - B1*s* K1 - B1^2*s^2

∆ = M1*M2*s^4 + M1*s^2*K1 + M1*s^2*K2 + M1*s^2* B1*s + M1*s^2* B2*s + M2*s^2* K1 + K2* K1 + B2*s* K1 + M2*s^3*B1 + K2* B1*s + B2*B1*s^2

X1(s) =

-------------------------------------------------------------------

12

M1*s^2 + K1 + B1*s -K1-B1*s

-K1-B1*s M2*s^2 + K1 + K2 + B1*s + B2*s

F(s) -K1-B1*s

0 M2*s^2 + K1 + K2 + B1*s + B2*s

Page 14: Lab Manual of Lcs

X1(s) M2*s^2 + K1 + K2 + B1*s + B2*s------- = -----------------------------------------------------------------------------F(s) (M1*M2*s^4 + M1*s^2*K1 + M1*s^2*K2 + M1*s^2* B1*s + M1*s^2* B2*s + M2*s^2* K1 + K2* K1 + B2*s* K1 + M2*s^3*B1 + K2* B1*s + B2*B1*s^2)

COMMANDS:

Two commands are used solve and syms which are already discussed in lab 2.

PROGRAM CODING:

syms X1 X2 M1 M2 s F B1 B2 K1 K2 eq1=X1*M1*s^2+X1*K1+X1*B1*s-X2*K1-X2*B1*s-Feq2=X2*M2*s^2+X2*K2+X2*B2*s+X2*K1+X2*B1*s-X1*K1-X1*B1*se=solve(eq1,eq2,X1,X2)e.X1/F

RESULT:ans = (M2*s^2+K1+B1*s+K2+B2*s)/(M2*s^4*M1+M2*s^2*K1+M2*s^3*B1+K1*M1*s^2+B1*s^3*M1+K2*M1*s^2+K2*K1+K2*B1*s+B2*s^3*M1+B2*s*K1+B2*s^2*B1)

ASSIGNMENT: Related Exercise problems.

LABORTARY EXERCISE # 6

OBJECTIVE:

To plot the graph of Sin, Cos and Tan.

13

Page 15: Lab Manual of Lcs

THEORY:

SUBPLOT, Create axes in tiled positions.H = SUBPLOT(m,n,p), or SUBPLOT(mnp), breaks the Figure window into an m-by-n matrix of small axes, selects the p-th axes for for the current plot, and returns the axis handle. The axes are counted along the top row of the Figure window, then the second row, etc. For example, SUBPLOT(2,1,1), PLOT(income) SUBPLOT(2,1,2), PLOT(outgo)

SIN,Sine of argument in radians.SIN(X) is the sine of the elements of X.

COS,Cosine of argument in radians.COS(X) is the cosine of the elements of X.

TAN,Tangent of argument in radians.TAN(X) is the tangent of the elements of X. COMMANDS: - SUBPLOT - SIN- COS- TAN

PROGRAM CODING:(a)x=0:0.001:10;y1=sin(x);subplot(2,2,1)plot(x,y1)xlabel('time')ylabel('amplitude')title('Sin graph')gtext('Mushahid')gridy2=cos(x);subplot(2,2,2)plot(x,y2)xlabel('time')ylabel('amplitude')title('Cos graph')gtext('Mushahid')

14

Page 16: Lab Manual of Lcs

gridx1=0:0.15:10;y3=tan(x1);subplot(2,2,3)plot(x1,y3)xlabel('time')ylabel('amplitude')title('Tan graph')gtext('Mushahid')grid

(b)x=0:0.001:10;y1=sin(x);plot(x,y1,'b')gtext('Sin')hold ony2=cos(x);plot(x,y2,'g')gtext('Cos')hold ony3=tan(x1);plot(x1,y3,'r')gtext('Tan')hold onxlabel('time')ylabel('amplitude')title('Basic Trignometry graph')gtext(‘Mushahid’)grid

RESULT:

15

Page 17: Lab Manual of Lcs

ASSIGNMENT: Related Exercise problems.

LABORTARY EXERCISE # 7

16

Page 18: Lab Manual of Lcs

OBJECTIVE:

To find the following with the help of canonical diagram,

(a) Transfer function to state space model.(b) and (c)State space model to transfer function.(d) Complete solution of state space model.

THEORY: G(s) = 1/(s^2+3*s+2)

u(s) + + y(s)

-

.x1= x2 – 3*x1 .x2= u - 2*x1

y= x1

COMMANDS: TF2SS,Transfer function to state-space conversion.[A,B,C,D] = TF2SS(NUM,DEN) calculates the state-space representation: . x = Ax + Bu, y = Cx + Du of the system:

NUM(s) H(s) = -------- DEN(s) from a single input. Vector DEN must contain the coefficients of the denominator in descending powers of s. Matrix NUM must contain the numerator coefficients with as many rows as there are outputs y. The A,B,C,D matrices are returned in controller canonical form. This calculation also works for discrete systems.

SS2TF,State-space to transfer function conversion.[NUM,DEN] = SS2TF(A,B,C,D,iu) calculates the transfer function:

17

s-1 s-1

2 3

Page 19: Lab Manual of Lcs

NUM(s) -1 H(s) = -------- = C(sI-A) B + D DEN(s) of the system: . x = Ax + Bu y = Cx + Du from the iu'th input. Vector DEN contains the coefficients of the nominator in descending powers of s. The numerator coefficients are returned in matrix NUM with as many rows as there are outputs y.

EYE,Identity matrix. EYE(N) is the N-by-N identity matrix. EYE(M,N) or EYE([M,N]) is an M-by-N matrix with 1's on the diagonal and zeros elsewhere. EYE(SIZE(A)) is the same size as A. EYE with no arguments is the scalar 1. EYE(M,N,CLASSNAME) or EYE([M,N],CLASSNAME) is an M-by-N matrix with 1's of class CLASSNAME on the diagonal and zeros elsewhere.Note: The size inputs M and N should be nonnegative integers. Negative integers are treated as 0.Example: x = eye(2,3,'int8');

DSOLVE,Symbolic solution of ordinary differential equations. DSOLVE('eqn1','eqn2', ...) accepts symbolic equations representing ordinary differential equations and initial conditions. Several equations or initial conditions may be grouped together, separated by commas, in a single input argument.By default, the independent variable is 't'. The independent variable may be changed from 't' to some other symbolic variable by including that variable as the last input argument.The letter 'D' denotes differentiation with respect to the independent variable, i.e. usually d/dt. A "D" followed by a digit denotes repeated differentiation; e.g., D2 is d^2/dt^2. Any characters immediately following these differentiation operators are taken to be the dependent variables; e.g., D3y denotes the third derivative of y(t). Note that the names of symbolic variables should not contain the letter "D".Initial conditions are specified by equations like 'y(a)=b' or 'Dy(a) = b' where y is one of the dependent variables and a and b are constants. If the number of initial conditions given is less than the

18

Page 20: Lab Manual of Lcs

number of dependent variables, the resulting solutions will obtain arbitrary constants, C1, C2, etc.Three different types of output are possible. For one equation and one output, the resulting solution is returned, with multiple solutions to a nonlinear equation in a symbolic vector. For several equations and an equal number of outputs, the results are sorted in lexicographic order and assigned to the outputs. For several equations and a single output, a structure containing the solutions is returned.If no closed-form (explicit) solution is found, an implicit solution is attempted. When an implicit solution is returned, a warning is given.If neither an explicit nor implicit solution can be computed, then a warning is given and the empty sym is returned. In some cases involving nonlinear equations, the output will be an equivalent lower order differential equation or an integral.

Examples:dsolve('Dx = -a*x') returnsans = C1*exp(-a*t)x = dsolve('Dx = -a*x','x(0) = 1','s') returnsx = exp(-a*s)y = dsolve('(Dy)^2 + y^2 = 1','y(0) = 0') returnsy =[ sin(t)][ -sin(t)]S = dsolve('Df = f + g','Dg = -f + g','f(0) = 1','g(0) = 2') returns a structure S with fieldsS.f = exp(t)*cos(t)+2*exp(t)*sin(t)S.g = -exp(t)*sin(t)+2*exp(t)*cos(t) dsolve('Dy = y^2*(1-y^2)') returns (Warning:Explicit solution could not be found; implicit solution returned)ans =t+1/2*log(y-1)-1/2*log(y+1)+1/y+C1=0dsolve('Df = f + sin(t)', 'f(pi/2) = 0')dsolve('D2y = -a^2*y', 'y(0) = 1, Dy(pi/a) = 0')S = dsolve('Dx = y', 'Dy = -x', 'x(0)=0', 'y(0)=1')S = dsolve('Du=v, Dv=w, Dw=-u','u(0)=0, v(0)=0, w(0)=1')w = dsolve('D3w = -w','w(0)=1, Dw(0)=0, D2w(0)=0')y = dsolve('D2y = sin(y)'); pretty(y)

PROGRAM CODING:(a)syms A B C Dn=1d=[1,3,2]

19

Page 21: Lab Manual of Lcs

[A,B,C,D]=tf2ss(n,d)

(b)A=[-3 -2;1 0]B=[1;0]C=[0 1]D=0[n,d]=ss2tf(A,B,C,D)

(c)syms G sA=[-3 -2;1 0]B=[1;0]C=[0 1]D=0I=eye(2)G=C*inv(s*I-A)*B+D

(d)g=dsolve('Dx1=-3*x1+x2,Dx2=-2*x1+1,x1(0)=x1,x2(0)=x2')g.x1g.x2

RESULT:(a)

A = -3 -2 1 0

B = 1 0

C = 0 1

D = 0

(b)

n = 0 0.0000 1.0000d = 1 3 2

(c)

G =1/(s^2+3*s+2)

20

Page 22: Lab Manual of Lcs

(d)

ans =-(-1/2-2*x1+x2)*exp(-2*t)+1/2*exp(-t)*(-2-2*x1+2*x2)+1/2 ans =3/2-(-1/2-2*x1+x2)*exp(-2*t)+exp(-t)*(-2-2*x1+2*x2)

ASSIGNMENT: Related Exercise problems.LABORTARY EXERCISE # 8

OBJECTIVE:

(a) Find the residues of G(s)=5/s+2,

(i) R(s) = unit step(1/s) (ii) R(s) = unit ramp(1/s^2)

(b) Find c(t),(i) R(s) = unit step(1/s) (ii) R(s) = unit ramp(1/s^2)

THEORY: G(s) = 5/(s+2)

Unit step,C(s)= G(s) R(s) = 5/s*(s+2) = 2.5/s - 2.5/(s+2).

Unit ramp,C(s)= G(s) R(s) = 5/s^2*(s+2) = 2.5/s - 1.5/s^2 + 1.5 /(s+2)

COMMANDS: RESIDUE,Partial-fraction expansion (residues).[R,P,K] = RESIDUE(B,A) finds the residues, poles and direct term of a partial fraction expansion of the ratio of two polynomials B(s)/A(s). If there are no multiple roots, B(s) R(1) R(2) R(n) ---- = -------- + -------- + ... + -------- + K(s) A(s) s - P(1) s - P(2) s - P(n)Vectors B and A specify the coefficients of the numerator and denominator polynomials in descending powers of s. The residues are returned in the column vector R, the pole locations in column vector P, and the direct terms in row vector K. The number of poles

21

Page 23: Lab Manual of Lcs

is n = length(A)-1 = length(R) = length(P). The direct term coefficient vector is empty if length(B) < length(A), otherwise length(K) = length(B)-length(A)+1. If P(j) = ... = P(j+m-1) is a pole of multplicity m, then the expansion includes terms of the form R(j) R(j+1) R(j+m-1) -------- + ------------ + ... + ------------ s - P(j) (s - P(j))^2 (s - P(j))^m [B,A] = RESIDUE(R,P,K), with 3 input arguments and 2 output arguments, converts the partial fraction expansion back to the polynomials with coefficients in B and A. ILAPLACE,Inverse Laplace transform. F = ILAPLACE(L) is the inverse Laplace transform of the scalar sym L with default independent variable s. The default return is a function of t. If L = L(t), then ILAPLACE returns a function of x: F = F(x).By definition, F(t) = int(L(s)*exp(s*t),s,c-i*inf,c+i*inf)where c is a real number selected so that all singularities of L(s) are to the left of the line s = c, i = sqrt(-1), and the integration is taken with respect to s.F = ILAPLACE(L,y) makes F a function of y instead of the default t: ILAPLACE(L,y) <=> F(y) = int(L(y)*exp(s*y),s,c-i*inf,c+i*inf).Here y is a scalar sym.F = ILAPLACE(L,y,x) makes F a function of x instead of the default t: ILAPLACE(L,y,x) <=> F(y) = int(L(y)*exp(x*y),y,c-i*inf,c+i*inf), integration is taken with respect to y.

PROGRAM CODING:(a)(i)n=[0 0 5]d=[1 2 0][R,P,K]=residue(n,d)

(ii)n=[0 0 0 5]d=[1 2 0 0][R,P,K]=residue(n,d)

(b)(i)syms silaplace(5/((s^2)+(2*s)))

(ii)syms silaplace(5/((s^3)+(2*s^2)))

22

Page 24: Lab Manual of Lcs

RESULT:(a)(i)R = -2.5000 2.5000P = -2 0K = []

(ii)R = 1.2500 -1.2500 2.5000P = -2 0 0K = []

(b)(i)ans =5*exp(-t)*sinh(t)

(ii)ans =5/2*t-5/2*exp(-t)*sinh(t)

ASSIGNMENT: Related Exercise problems.

23

Page 25: Lab Manual of Lcs

LABORTARY EXERCISE # 9

OBJECTIVE:

Find step response,(i) R(s) = unit step(1/s) (ii) R(s) = unit ramp(1/s^2)

THEORY: G(s) = 5/(s+2)

Unit step,C(s)= G(s) R(s) = 5/s*(s+2) = 2.5/s - 2.5/(s+2).

Unit ramp,C(s)= G(s) R(s) = 5/s^2*(s+2) = 2.5/s - 1.5/s^2 + 1.5 /(s+2)

COMMANDS:

STEP, Step response of LTI models.STEP(SYS) plots the step response of the LTI model SYS (created with either TF, ZPK, or SS). For multi-input models, independent step commands are applied to each input channel. The time range and number of points are chosen automatically.STEP(SYS,TFINAL) simulates the step response from t=0 to the final time t=TFINAL. For discrete-time models with unspecified sampling time, TFINAL is interpreted as the number of samples.STEP(SYS,T) uses the user-supplied time vector T for simulation. For discrete-time models, T should be of the form Ti:Ts:Tf where Ts is the sample time. For continuous-time models,T should be of the form Ti:dt:Tf where dt will become the sample time for the discrete

24

Page 26: Lab Manual of Lcs

approximation to the continuous system. The step input is always assumed to start at t=0 (regardless of Ti).

PROGRAM CODING:(i)g=tf([0 5],[1 2])step(g)

(ii)g=tf([0 0 5],[1 2 0])step(g)

RESULT:

25

Page 27: Lab Manual of Lcs

ASSIGNMENT: Related Exercise problems.LABORTARY EXERCISE # 10

OBJECTIVE:

To find the step response of second order system for different values of zeta.

THEORY: Case 1:When value of ζ=0 the system is undamped, the system has constant oscillations.

Case 2:When value of 0<ζ<1 the system is underdamped, the system has overshoots.

Case 3:When value of ζ=1 the system is criticallydamped, the system has no overshoots with smallest settling time.

Case 4:When value of ζ>1 the system is over damped, the system has no overshoots with settling time greater than critically damped system.

26

Page 28: Lab Manual of Lcs

COMMANDS: FOR,Repeat statements a specific number of times. The general form of a FOR statement is:

FOR variable = expr, statement, ..., statement END

The columns of the expression are stored one at a time in the variable and then the following statements, up to the END, are executed. The expression is often of the form X:Y, in which case its columns are simply scalars. Some examples (assume N has already been assigned a value).

for R = 1:Nfor C = 1:NA(R,C) = 1/(R+C-1);endend Step S with increments of -0.1 for S = 1.0: -0.1: 0.0, do_some_task(S), end Set E to the unit N-vectors for E = eye(N), do_some_task(E), end

Long loops are more memory efficient when the colon expression appears in the FOR statement since the index vector is never created. The BREAK statement can be used to terminate the loop prematurely.

PROGRAM CODING:zeta=[0 0.2 0.5 1 2];for k=1:5n=[0 0 1]d=[1 2*zeta(k) 1];g=tf(n,d);T=40step(g,T)hold onendlegend('UNDAMPED WHEN \zeta=0','UNDERDAMPED WHEN \zeta=0.2','UNDERDAMPED WHEN \zeta=0.5','CRITICAL DAMPED WHEN \zeta=1','OVERDAMPED WHEN \zeta=2')

RESULT:

27

Page 29: Lab Manual of Lcs

ASSIGNMENT: Related Exercise problems.

LABORTARY EXERCISE # 11

OBJECTIVE:

The block diagram of a position control servo mechanism is given below, find step response, maximum peak amplitude, steady state value, peak time and settling time.

THEORY: Servo motor R(s) + Kp + C(s)

- - Kd

28

0.2 920

s(s+4)

0.16s

Page 30: Lab Manual of Lcs

sensor

G(s) = 36/(s^2 + 7.2 s + 36)

Solution:

DC gain = 1

Wn = √36 = 6

2ζWn = 7.2

ζ = 0.6 (system is underdamped)

Mpt = 1+ e - ζ ∏ / √1 - 2 ζ^2 = 1.09

Tp = ∏ / Wn √1 - 2 ζ^2 = 0.65 sec

Ts = 4/ ζWn = 1.11 sec

Css = DC gain * constant input = 1*1 = 1

COMMANDS: LTIVIEW,

LTIVIEW opens an empty LTI Viewer. The LTI Viewer is an interactive graphical user interface (GUI) for analyzing the time and frequency responses of linear systems and comparing such systems. See LTIMODELS for details on how to model linear systems in the Control System Toolbox.

LTIVIEW(SYS1,SYS2,...,SYSN) opens an LTI Viewer containing the step response of the LTI models SYS1,SYS2,...,SYSN. You can specify a distinctive color, line style, and marker for each system, as in

sys1 = rss(3,2,2); sys2 = rss(4,2,2); ltiview(sys1,'r-*',sys2,'m--');

LTIVIEW(PLOTTYPE,SYS1,SYS2,...,SYSN) further specifies which responses to plot in the LTI Viewer. PLOTTYPE may be any of the following strings(or a combination thereof): 1) 'step' Step response 2) 'impulse' Impulse response 3) 'lsim' Linear simulation plot 4) 'initial' Initial condition plot 5) 'bode' Bode diagram 6) 'bodemag' Bode Magnitude diagram 7) 'nyquist' Nyquist plot 8) 'nichols' Nichols plot 9) 'sigma' Singular value plot 10) 'pzmap' Pole/Zero map 11) 'iopzmap' I/O Pole/Zero map

29

0.2

Page 31: Lab Manual of Lcs

For example,

ltiview({'step';'bode'},sys1,sys2)opens an LTI Viewer showing the step and Bode responses of the LTI models SYS1 and SYS2.

LTIVIEW(PLOTTYPE,SYS,EXTRAS) allows you to specify the additional input arguments supported by the various response types. See the HELP text for each response type for more details on the format of these extra arguments. If an LSIM plot is specified without additional input arguments, the Linear Simulation Tool automatically opens so that initial states and/or driving inputs can be assigned interactively.

H = LTIVIEW(...) opens an LTI Viewer and returns the handle to the LTI Viewer figure.

Two additional options are available for manipulating previously opened LTI Viewers:

LTIVIEW('clear',VIEWERS) clears the plots and data from the LTI Viewers with handles VIEWERS.

LTIVIEW('current',SYS1,SYS2,...,SYSN,VIEWERS) adds the responses of the systems SYS1,SYS2,... to the LTI Viewers with handles VIEWERS.

PROGRAM CODING:

s=tf('s')g1=20/(s*s+4*s)g2=0.16*sp1=feedback(g1,g2,-1)p2=series(p1,9)p3=feedback(p2,0.2,-1)g=series(0.2,p3)ltiview('step',g)

RESULT:

30

Page 32: Lab Manual of Lcs

ASSIGNMENT: Related Exercise problems.

LABORTARY EXERCISE # 12

31

Page 33: Lab Manual of Lcs

OBJECTIVE:

Sketch the root locus using rlocus command.

(i) K*G(s)*H(s) = K(s+1)/s^2

(ii) K*G(s)*H(s) = K/s(s+2)^2

(ii) K*G(s)*H(s) = K/s[(s+10)^2 + 1]

THEORY: RLOCUS,Evans root locus. RLOCUS(SYS) computes and plots the root locus of the single-input, single-output LTI model SYS. The root locus plot is used to analyze the negative feedback loop +-----+ ---->O----->| SYS |----+----> -| +-----+ | | | | +---+ | +-------| K |<----+ +---+ and shows the trajectories of the closed-loop poles when the feedback gain K varies from 0 to Inf. RLOCUS automatically generates a set of positive gain values that produce a smooth plot. RLOCUS(SYS,K) uses a user-specified vector K of gain values. RLOCUS(SYS1,SYS2,...) draws the root loci of multiple LTI models SYS1, SYS2,... on a single plot. You can specify a color, line style, and marker for each model, as in rlocus(sys1,'r',sys2,'y:',sys3,'gx'). [R,K] = RLOCUS(SYS) or R = RLOCUS(SYS,K) returns the matrix R of complex root locations for the gains K. R has LENGTH(K) columns and its j-th column lists the closed-loop roots for the gain K(j).

COMMANDS: - RLOCUS

PROGRAM CODING:

(i) rlocus([0 1 1],[1 0 0])

(ii)

32

Page 34: Lab Manual of Lcs

rlocus([0 0 0 1],[1 4 4 0])

(ii) rlocus([0 0 0 1],[1 20 101 0])

RESULT:(i)

(ii)

33

Page 35: Lab Manual of Lcs

(iii)

ASSIGNMENT: Related Exercise problems.

34