You are on page 1of 15
14 | Control Systems The following are the other examples of a regulating system (i) temperature regulators, (ii) frequency regulators, and (iii) speed governors 1.11 Introduction to MATLAB Double-click on the MATLAB ® icon on the desktop, or navigate through the program menu to open the MATLAB window. After the program is initialized, we will get a command window where the MATLAB commands can be written. It is the command prompt of MATLAB. There will be pull-down menu where the current directory will be mentioned. Current directory:c:\MATLABphwork. Store the present files in the present directory so that the programs can be directly invoked from the command prompt. All the MATLAB commands together form a MATLAB file (.m extension) and can be executed as a program rather than commandwise execution. MATLAB which is a high-performance language for technical computing has the capability to inte- grate computation, visualization, and programming in an easy-to-use environment. The problems and solutions can be expressed in familiar mathematical notation. The following are the typical uses: Math and computation Algorithm development Modeling, simulation, and prototyping . . . = Data analysis, exploration, and visualization = Scientific and engincering graphics . Application development, including graphical user interface building operators Expressions use familiar arithmetic operators and precedence rules. + Addition ~ Subtraction * Multiplication / Division \ Left division “* Power " Complex conjugate transpose ( Specify evaluation order 1.12 MATLAB Variables MATLAB variables can be directly created as >>d=5 Putting a semicolon at the end does not reflect the output. Sometimes, an object of the symbol is required during MATLAB operation (for example, Fourier transform). It will be dealt with separately. 2.21 MATLAB Commands for Matrix The best way to learn MATLAB is to learn matrix manipulation in MATALB. There are several ways of defining a matrix-one of which is the explicit declaration. The following rules are to be followed while entering the matrix: u Separate the elements of the row by spaces or commas. a Separate the end of the rows by semi colons. a Surround the entire list by square brackets. For example, A=[1234;5678] The matrix displayed will be A= 1 2 3 4 5.6 #7 8 sum (A) will give the sum of the column as a row vector as given below: 6 8 10 12 A’ gives the transpose of the matrix 1 5 2 6 3 7 4 8 36 | Control Systems It is also possible to transfer the matrix elements by subscripts. For example (1,1) responds | as the output. A(2,3) responds 7 as output 2.21.1 Matrix Multiplication ‘Two compatible matrices can be multiplied using **" operator. For example, B=(1234] C=]; 2; 3;4] Ans. 30 Deere Similarly, other operations, such as addition and subtraction, can be performed on two compatible matrices. 2.21.2 Inverse of the Matrix The inverse of the matrix can be calculated using the command inv. For example, >>d=[100;010;001]; >> det( A) 1 >> inv(A) coe oro 0 0 1 2.21.3 Eigenvalue The eigenvalue can be calculated using eig function. >> eig(A) 1 1 1 There are some other matrix functions which cater to different needs. wp 14 14 Program 1 If A -| na B= ; A} using suitable MATLAB program obtain the matrix A and B with dis- play and without display, addition of A and B, multiplication of A and B, determinant of A and B, inverse of A and B, cigen values of A and B, multiplication of inverse of A twice and thrice, multiplication of A two and four times, rank of A and B, transpose of A and B. Solution >> % Display the matrix A >> A=[ 14526] A= 1 4 2 6 >> % Do not display the matrix A >>A=[1 4; 26); >> % Display the matrix B >> B=[14;39] B= ioe, so Laplace Transform and Matrix Alge’ >> % Do not display the matrix B >> B=[14;39]; >> % Add matrix 4 and matrix B and display the result >>CaAtB ly A and B and display the result 13° 40 20 62 >> % Find determinant of matrix >> det(d) ans= 2 >> % Find determinant of matrix B >> det(B) ans = 3 >> % Find inverse of matrix A >> inv(d) ans= 3.0000 2.0000 1.0000 -0.5000 >> % Find inverse of matrix B >> inv(B) ans = 3.0000 1.3333 1.0000 -0.3333 >> % Eigen value of A >> eig(A) ans 0.2749 71.2749 >> % Eigen value of B >> eig(B) ans = 0.2915 10.2915 >>%A(-2) effectively multiplies inv(A) by itself 2 — 1 times >> AN-2) ans= | 11,0000 ~7.0000 -3.5000 2.2500 >> % A"(-3) effectively multiplies inv(A) by itself 3 - 1 times >> AN-3) ans = ~40.0000 25.5000 12.7500 -8.1250 44 | control systems >> % Multiplication of 4 by one time ie, >> Ard ans = 9 Bw 14 44 >> % Multiplication of A by four times i.e., 5 ~ 1 = 4 times >> Ars ans = 3441 10796 5398 16936 >> rank(A) ans = 2 >> rank(B) ans = 2 >>A’ ans = 12 4 6 >> Be ans = 1 4 > 3 9 14 9 Program 2 Obtain suitable MATLAB program for the matrix A=|2 8 10] to obtain the following: 36 9 (j) display it, (ii) determinant of the matrix A, (iii) inverse of A, (iv) transpose of A, (v) multiplication of 4 twice, (vi) multiplication of A six times, (vii) multiplication of inverse of A twice, (viii) multiplication of inverse of 4 thrice and (ix) rank of 4. Solution >>A=[1 49:2 8 10;3 6 9] 0.2500 -0.3750 0.6667 0.2500 0.3750 -0.1667 0.2500 -0.1250 0 >>d’ ans= 1023 486 9 10 9 >and ans = 36 90 130 48. 132 188 42 114 168 >> AT ans = 66562056 180049104 261252504 95977296 259616736 376705584 84438504 228404448 331416360 >> AN-2) ans = 03229 0.1302 -0.1042 0.0729 0.2552 -0.2292 0.0313 0.1406 0.1875 >> dd) ans = 0.1170 -0.0606 -0.0233 0.0350 0.1069 -0.0939 0.0057 -0.0582 0.0706 >> rank() ans = 3 > v Program 3 Find the Laplace transform of g(t Solution >> syms t >>a=exp(-3*t)*(1 — sin(t)) ~.sin(t) — 1Y/exp(3*t) >> laplace(a) ans = 1(s-+3)— W(s + 3)°2 + 1) > Laplace Transform and Matrix Algebra | 45 ((1-sin t), Find the transfer function of the system. \Pfogram 4 Use MATLAB for partial fraction expression expansion for the following transfer function S+3s+2 9 +123? +475 +60 Solution >>num=[1 3 2] num = 132 F(s) 46 | Controt Systems >>dea=(1 12 47 60) den = 112 47 60 >> (t, p, k] = residue(mum, den) r= 6.0000 6.0000 1.0000 p= 8.0000 4.0000 0000 k ou Program § Use MATLAB for partial fraction expression expansion for the following transfer function s+35+4 FO" Ty astaSsa2 ‘Solution >>num=[1 3 4] 1452 >> [rp k] = residue(num, den) r= 2.0000 1.0000 2.0000 P 2.0000 Program 6 Use MATLAB for partial fraction expression expansion for the following transfer function 24s +6 ££) —— = Tyas tas +212 Solution >>num=[1 4 6] num = 14 6 >>den=[1 8 23 28 12] den = 1 823 28 12 Laplace Transform and Matrix Algebra | 47 residue(num, den) Program 7 Use MATLAB for partial fraction expression expansion for the following transfer function 2st +25? +35? +55+10 Fs)= st+ lls? +415 + 61s +30 Solution >> num = [223 5 10] num = 22.3 5 10 >> den =[1 11 41 61 30] den = 1 11 41 61 30 >> [r, p, k] = residue(num, den) r= 44.1667 32.5000 9.3333 1.0000 3.0000 0000 Program 8 Use MATLAB for partial fraction expression expansion for the following transfer function st+3s45 F(s)= 2345 _ (= Ty 6st + 12548 Solution >>num=[1 2 5] num 1255 >>den=[1 6 12 8] 48 | Control Systems den = 1612 8 >> [1 p, k] = residue(num, den) re 1,0000 2.0000 5.0000 0 Program 9 Use MATLAB for partial fraction expression expansion for the following transfer function 2 FOS Sasa Solution >> num = [02] num = 0 2 >> den =[13900] den= 13900 >> [r.p, kJeresidue(num, den) r= 0.0370 + 0.02141 0.0370 - 0.02141 0.0741 0.2222 pe 1.5000 + 2.59811 1.5000 = 2.5981 0 0 0g Program 10 Use MATLAB for partial fraction expression expansion for the following transfer function 2s+t S843 +95?” F(s)= Solution >> num = (2 1] qum = 21 +> den =[139000] den= 13 9 0 0 0 >> [t, p, k]=residue(num, den) r= 0.0370 + 0.0143i 0.0370 — 0.0143: -0.0741 0.1852 0.1111 p= -1,5000 + 2.5981i -1.5000 — 2.5981i Laplace Transform and Matrix Alget MATLAB Programs . i st+5s+4 Program 1 Find zeros, poles and gain ofthe transfer function F(s) = ===" 5S eae sing MATLAB Solution >>num=[1 5 4] num = oo. >>den=[1 16 91 216 180) den = 1 16 91 216 180 >> [z, p, k] =tf2zp(num, den) ze 4 -1 p= -6.0000 —5.0000 -3.0000 -2.0000 k 1 5s? +305 +25 i les and gai i Soren Program 2 Find zeros, poles and gain of the transfer function F(s)=—<———=> oo sie MATLAB. Solution >>num=[5 30 25] num = 5 30 25 >>den=[1 16 89 206 168] den 1 16 89 206 168 Transfer Function | 71 >> [z, p. k] = tf2zp(num, den) z -s Program 3 Ifthe zeros and poles of the system having gain 6 are at -1, ~4.and -2,-3,—5 ,-7 respectively. find the transfer function of the system using MATLAB. Solution >>2=[-1;-4] >> [mum, den] = 2p2tf{zqp, k) num = 0 0 6 30 24 den = 1 17 101 247 210 >> printsys(num,den,'s') num/den = 6892 +308+24 84 +1783 + 101 2 +2478 +210 Program 4 Ifthe zeros and poles of the system having gain 5 are at -1, -3 and -2,—4, -$ ,—7 respectively, find the transfer function of the system using MATLAB. Solution >>z=[-1-3] lz | Control Systems. >> (mum, den] = zp2tftz, p. k) num = 0 0 5 2 15 den = 1 18 115 306 280 >> printsys(num,den,'s') num/den = 58°2+20s+15 84 + 18 873 + 115 8/2 +3065 +280 Program 5 Ifthe zeros and poles of the system having gain 7 are at ~1, -8 and -2, -3, ~6 .-7 respectively. the transfer function of the system using MATLAB. Solution >> [num, den] = zp2tftz, p, k): >> printsys(num.den,'s') num/den = 78/2 +638 +56 84 +18 993 + 113 592 +288 s+ 252 Program 6 The transfer function of a system is shown below: G(s) = —25+35+5)_ Find the transfer function and pole-zero plot of the system using MATLAB Sis-+2\s? +6547) >>pl=[13]: >> p2=[1 5]; >> num = conv(pl,p2); >> num = S¢num num = 5 40 75 >>ql =[1 0}; >>q2=[1 2 >> q3=[167]; >> den = conv(ql,q2); >> den = conv(den.q3) den = 1819 4 0 >> % command tf >> sys = tf{num,den) Transfer function: 58924405475 s4485°S +1982 +145 >> % command printsys >> printsys(num,den) num/den = 58924405475 SM+85°3 +1954 145 >> pzmap(sys); > Pole-Zero Map ‘Transfer Function | 73 O48 | -06 1 08 i . 1 1 L 1 45 4 35 3 25 1S 1 050 Real Axis

You might also like