LABORATORY TASK 2: MATLAB’S SYMBOLIC MATH TOOLBOX

1. OBJECTIVES At the end of the experiment, students should be able to 1) Perform Laplace and inverse Laplace transforms 2) Simplify complex transfer function 2. INTRODUCTION Symbolic math commands are used in MATLAB M-files right along with your standards MATLAB statements. The only additional requirement is to declare symbolic variable before they are used with the statement syms x1 x2 …., where xi are symbolic variables. Some of the added capabilities that the Symbolic Math Toolbox yields for control systems analysis and design include the following: a. b. c. d. functions and equations can be entered symbolically symbolic expressions can be manipulated algebraically and simplified transfer functions can be typed almost as written Laplace and z-transforms as well as their inverses can be entered and found in symbolic form

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.

3. PROCEDURES Open the MATLAB’s icon from the Desktop. Select File > New > M-File. Write down the codes from Exercise#1. Exercise #1
'Ex1 - Inverse Laplace Transform' syms s F = 2/[(s + 1)*(s + 2)^2]; 'F(s)' pretty(F) f = ilaplace(F) 'f(t)' pretty(f) F = 3/[s*(s^2 + 2*s + 5)]; 'F(s)' pretty(F) f = ilaplace(F) 'f(t)' pretty(f) %Display label %Construct symbolic object for %Laplace variable 's' %Define F(s) %Display label %Pretty print F(s) %Find inverse Laplace transform %Display label %Pretty print f(t) %Define F(s) %Display label %Pretty print F(s) %Find inverse Laplace transform %Display label %Pretty print f(t)

Select File > Save As. Save the file as Lab2Ex1. Select Debug > Run to run the program. Repeat above steps for the following exercises and save files appropriately. 1

Exercise #2
'Ex2 - Laplace Transform' syms t %Display label %Construct symbolic object for time %variable 't' 'f(t)' %Display label f = 2*exp(-t) - 2*t*exp(-2*t) - 2*exp(-2*t); %Define f(t) pretty(f) %Pretty print f(t) 'F(s)' %Display label F = laplace(f); %Find Laplace Transfrom pretty(F) %Pretty print F(s) F = simplify(F) %Combine partial fractions pretty(F) %Pretty print F(s) 'f(t)' %Display label f = 3/5 - 3/5*exp(-t)*[cos(2*t) + (1/2)*sin(2*t)]; %Define f(t) pretty(f) %Pretty print f(t) 'F(s)' %Display label F = laplace(f); %Find Laplace Transform pretty(F) %Pretty print F(s) 'F(s), Decimal representation' %Display label F = vpa(F,3); %Convert symbolic numerical %fractions to 3-place decimal pretty(F) %Pretty print F(s) 'F(s), Simplified' %Display label F = simplify(F); %Comine partial fraction pretty(F) %Pretty print F(s)

Exercise #3
'Ex3 – Simplified complicated transfer function syms s %Construct symbolic object for %frequency variable 's' G = 54*(s + 27)*(s^3 + 52*s^2+37*s +73) / (s*(s^4 + 872*s^3 + 437*s^2 + 89*s + 65)*(s^2 + 79*s +36)); %Define G(s) 'Symbolic G(s)' %Display label pretty(G) %Pretty print G(s) [num,den] = numden(G); %Extract symbolic numerator and %denominator num = sym2poly(num); %Form vector for numerator of G(s) den = sym2poly(den); %Form vector for denominator of G(s) 'LTI G(s) in Polynomial Form' %Display label Gtf = tf(num,den) %Form and display G(s) in polynomial %form 'LTI G(s) in Factored Form' %Display label Gzpk = zpk(Gtf) %Convert G(s) to factored form.

4. DISCUSSION

(CO3)

1. Find the Laplace transform of the following time function: 5 10 3t 40 3t f (t ) 5e 2t te e 9 3 9 2. Find the inverse Laplace transform of the following frequency function: s 3 4s 2 6s 5 G( s) ( s 8)(s 2 8s 3)(s 2 5s 7)

2

3. Use MATLAB and the symbolic Math Toolbox to input and form LTI objects in polynomial and factored form for the following frequency function: ( s 3 4s 2 6s 5)(s 3) G( s) ( s 8)(s 2 8s 3)(s 2 5s 7)

5. CONCLUSION List out what you have learned from this experiment. 6. REFERENCE [1] [2] [3] [4] Nise, Norman S., Control Systems Engineering, 4rd editions, John Wiley, 2000. ISBN: 0471366013 Dorf, R.C. & Bishop, R.H. Modern Control Systems, Addison Wesley (1995) (7th. Edn,) ISBN: 0201845598 Using Simulink Version 6 Using MATLAB Version 6

3

Sign up to vote on this title
UsefulNot useful