Professional Documents
Culture Documents
6 Modeling in Frequency Domain OBGECTIVE: To learn to use MATLAB and the Symbolic Math Toolbox to: (1) find Laplace transform for time functions, (2) find the time functions for the Laplace transforms, (3) create LTI transfer functions from symbolic transfer functions, (4) perform solution of symbolic simultaneous equations. SOFTWARE: MATLAB, the Symbolic Math Toolbox, the Control System Toolbox PRELAB: 1. Using a hand calculation, find the Laplace transform of: a. b.
POSTLAB: 1. Discuss the advantages and disadvantages between the Symbolic Math Toolbox and MATLAB alone to convert a transfer function from factored form to polynomial form and vice versa.
I2(s)=
5 ) (2 3s ) 1(0) s I 2S ! 5 5 2 2s (7 5s)(3 3s ) (2 3s)2 (1 2s) (1 2s)(3 3s ) (2 3s) 1?(1 2s)(2 3s) (7 5s) A s s 5 VS (1 2s )(3 3s ) (2 3s ) s I 2S ! 5 35 2 2 2 2 2s (6s 24s 77 s ) 1 2s (6s 12s 15 s ) 1(6s 12s 9) VS (6s 3 12s 2 15s 5) I 2S ! 70 5 12s 2 48s 84 70 12s 3 48s 2 84s 6s 2 12s 9 6s 2 12s 15 12s 3 24s 2 30s 10 s s 3 2 V (6s 12s 15s 5) I 2S ! S 65 24s 2 78s 120 s 3 2 V (6s 12s 15s 5) I 2S ! S 3 24s 78s 2 120s 65 4I 2S 4(6 s 3 12 s 2 15s 5) V G( S ) ! O ! ! 24 s3 78s 2 120s 65 Vi Vs
2 2s 0 VS (1 2s )(3 3s
I1(s)=
5 VS (7 5s)(3 3s ) (2 3s)2 s I1S ! 5 5 2 2s (7 5s)(3 3s ) (2 3s)2 (1 2s) (1 2s)(3 3s ) (2 3s) 1?(1 2s)(2 3s) (7 5s)A s s 5 VS (7 5s)(3 3s ) (2 3s)2 s I1S ! 5 35 2 2 2 2 2s (6s 24s 77 s ) 1 2s (6s 12s 15 s ) 1(6s 12s 9) I1S ! VS (6s3 24s2 42s 35) 12s2 48s 84 70 70 5 12s3 48s 2 84s 6s 2 12s 9 6s 2 12s 15 12s3 24s 2 30s 10 s s 3 2 V (6s 24s 42s 35) I1S ! S 3 24s 78s2 120s 65
I3(s)=
I 3S !
VS ?(1 2s)(2 3s) 7 5sA 5 5 2 2s (7 5s)(3 3s ) (2 3s)2 (1 2s) (1 2s)(3 3s ) (2 3s ) 1?(1 2s )(2 3s ) (7 5s)A s s VS ?(1 2s)(2 3s) 7 5sA 35 5 2 2 2 2 2s (6s 24s 77 s ) 1 2s (6s 12s 15 s ) 1(6s 12s 9) VS (6s2 12s 9) 12s2 48s 84 70 70 5 12s3 48s2 84s 6s2 12s 9 6s2 12 s 15 12 s3 24 s2 30 s 10 s s
I 3S !
I 3S !
VS (6s 2 12s 9) 65 24s2 78s 120 s 2 sVS (6s 12s 9) I 3S ! 24s3 78s 2 120s 65 I 3S !
LABORATORY: Use MATLAB and the Symbolic Math Toolbox to: a) Generate symbolically the time function f (t) shown in Prelab 1 and find the Laplace transform.
>>syms t f =t^2*cos (4*t); pretty (f) F=laplace(f); simplify (F) pretty (ans) 2 t cos(4 t) ans = (2*s*(s^2 - 48))/(s^2 + 16)^3 2 2 s (s - 48) ------------2 3 (s + 16)
>>syms t >>f2= 5*t*exp(-2*t)*sin(4*t); >> pretty (f2) 5 t sin(4 t) -----------exp(2 t) >> F2=laplace(f2); >>pretty(ans) 20 (2 s + 4) ---------------2 2 ((s + 2) + 16)
b) Generate symbolically the F(S) shown in Prelab 2 and find the Inverse Laplace transform.
>>syms s >> F3= 3/(s*(s^2+2*s+5)); >>pretty(F3) 3 ---------------2 s (s + 2 s + 5) >> f3=ilaplace(F3); >>pretty(f3) / sin(2 t) \ 3 | cos(2 t) + -------- | 3 \ 2 / - - ------------------------5 5 exp(t) >>
c). Solve for the transfer function, G(S) = Vo(s) / V(s). Use both the mesh and nodal equations and show that either set yields the same transfer function.
syms s x x= 'V(s)'; denominator=[(2*s)+2 (-2*s)-1 -1; (-2*s)-1 (5*s)+7 (-3*s)-2; -1 (-3*s)-2 (3*s)+3+(5/s)]; a=[(2*s)+2 (-2*s)-1 -1; (-2*s)-1 (5*s)+7 (-3*s)-2; -1 (3*s)-2 (3*s)+3+(5/s)]; a([4])= [x]; a([5 6])= [0]; b2=a; den=det(denominator); % I2(s) num2=det(b2); I2=num2/den; 'I2(s)' r2= simplify(I2); pretty(r2) 'G(s)= Vo(s)/V(s)' G= 4*r2/x; pretty(G) ans = I2(s) 3 2 V(s) (6 s + 12 s + 15 s + 5) -----------------------------3 2 24 s + 78 s + 120 s + 65 ans = G(s)= Vo(s)/V(s) 3 2 4 (6 s + 12 s + 15 s + 5) --------------------------3 2 24 s + 78 s + 120 s + 65
POSTLAB:
1.
Discuss the advantages and disadvantages between the Symbolic Math Toolbox and MATLAB alone to convert a transfer function factored form to polynomial form and vice versa.
Symbolic Math Toolbox lets you input expressions or equations on their usual form while in MATLAB alone , you have to specify the coefficients of each ter.
2. Discuss the advantages and disadvantages of using the Symbolic Math Toolbox to generate LTI transfer functions.
MATLAB's Symbolic Math Toolbox may be used to simplify the input of complicated transfer functions as follows: Initially, input the transfer function G(s) = numg/deng via symbolic math statements. Then convert G(s) to an LTI transfer function object. This conversion is done in two steps. The first step uses the command [numg,deng]=numden(G) to extract the symbolic numerator and denominator of G. The second step converts, separately, the numerator and denominator to vectors using the command sym2poly(S), where S is a symbolic polynomial. The last step consists of forming the LTI transfer function object by using the vector representation of the transfer function's numerator and denominator.
3. Discuss the advantages of using the Symbolic Math Toolbox to solve simultaneous equations of the type generated by the electric network in Prelab 3. Is it possible to solve the equations via MATLAB alone? Explain.
MATLAB's Symbolic Math Toolbox may be used to simplify the solution of simultaneous equations by using Cramer's rule. A system of simultaneous equations can be represented in matrix form by Ax = B, where A is the matrix formed from the coefficients of the unknowns in the simultaneous equations, x is a vector containing the unknowns, and B is a vector containing the inputs. Cramer's rule states that xk, the kth element of the solution vector, x, is found using xk = det(Ak)/det(A),where Ak is the matrix formed by replacing the kth column of matrix A with the input vector, B. In the text we refer to det(A) as "delta". In MATLAB matrices are written with a space or comma separating the elements of each row. The next row is indicated with a semicolon or carriage return. The entire matrix is then enclosed in a pair of square brackets.
4. Discuss any other observation you had using the Symbolic Math Toolbox.
Symbolic Math Toolbox expressions are much simpler and readable than MATLAB alone.
CONCLUSION:
Upon the completion of exercise 6,we found out that MATLAB's calculating power is greatly enhanced using the Symbolic Math Toolbox. In this example we demonstrate its power by calculating inverse Laplace transforms of F(s). The beginning of any symbolic calculation requires defining the symbolic objects. For example, the Laplace transform variable, s, or the time variable, t, must be defined as a symbolic object. This definition is performed using the syms command. Thus, syms s defines s as a symbolic object; syms t defines t as a symbolic object; and syms s t defines both s and t as symbolic objects. We need only define objects that we input to the program. Variables produced by the program need not be defined. Thus, if we are finding inverse Laplace transforms, we need only define s as a symbolic object, since t results from the calculation. Once the object is defined, we can then type F as a function of s as we normally would write it. We do not have to use vectors to represent the numerator and denominator. The Laplace transforms or time functions can also be printed in the MATLAB Command Window as we normally would write it. This form is called pretty printing. The command is pretty(F), where F is the function we want to pretty print. In the code below, you can see the difference between normal printing and pretty printing if you run the code without the semicolons at the steps where the functions, F or f, are defined. Once F(s) is defined as F, we can find the inverse Laplace transform using the command ilaplace(F). MATLAB's Symbolic Math Toolbox, with its ability to perform matrix operations, lends itself to the Laplace transform solution of state equations. Hence, with this we can manipulate expressions much simpler and readable.
EXERCISE No.6
CONTROL SYSTEM
(Modeling in the Frequency Domain)