1. Laplace Transform
Laplace transform of a function f(t) is defined as
Laplace transform of a function f(t) can be obtained with Matlab's function laplace.
Syntax: L =laplace(f)
The usage is demonstrated in the following examples.
Find the Laplace transform of
Matlab performs Laplace transform symbolically. Thus, you need to first define the variable t as a "symbol".
>> syms t
Next, enter the function f(t):
Finally, enter the following command:
Matlab yields the following answer:
You may want to carry out the transformation by hand (or using Laplace transform table) to verify this result.
Find the Laplace transform of:
In Matlab Command Window:
Note that the function y(t) is defined as symbol with the imbeded command "sym". The number 2 means we wish to take the second derivative of the function y(t).
where y(0) is the initial condition.
Find the inverse Laplace transform of
In Matlab Command window:
which is the solution of the differential equation
As an exercise, you should carryout the Laplace transform of the above differential equation with initial condition y(0) = 0 to arrive to the expression of Y(s) as shown above.
As defined in class, the state of a system is a set of variables such that the knowledge of these variables and the input functions will, with the equations describing the dynamics, provide the future state and output of the system. The state of the system is described by the set of the first-order differential equations written in terms of state variables (x1, x2, x3, ..., xn). These first-order differential equations can be written in a general form that can be represented in matrix notation:
where u is a vector of the inputs, x is the element state vector, and y is a vector containing outputs.
Consider an RLC series circuit as shown in the figure below:
Using Kirchhoff's voltage law, we obtain a differential equation that can be reduced to a set of first-order system:
in matrix form:
Assuming we can measure Vc, then the output relationship can be described by
We will analyze this problem with a step input.
In MATLAB you can create an "M-file" including the model parameters. To create an M-file, go to FILE menu and select NEW > M-file. An editor window will pop up. Enter the 12 lines as shown below.
Save the file to directory where you can specify the path from the MATLAB command window. Once saved, this M-file can be loaded (executed) by simply go to the appropriate directory and call the M-file by its name. For example, if the above M-file was saved as "rlc.m" ( the extension .m is appended by MATLAB automatically), in MATLAB, simply enter "rlc" at the command prompt to execute the program and enter the requested value accordingly.
NOTE: Make sure not to save your M-file with a name that is the same as a Matlab reserved word or function name.
The out put of the step response is shown below:
Grids can be shown on the plot with the "grid" command either in your M-file script or at the command line.
3. Converting State-Space to Transfer Function.
You may find it useful to obtain a transfer function of the system from the state-space representation. This can be achieved by using the MATLAB's function "ss2tf". In the example above, the matrices A, B, C, D were computed according to the user-defined parameters. We will use the computed values from Example 4 above to demonstrate the use of the "ss2tf" command. A screenshot of the conversion with the computed values of A, B, C, and D matrices are shown below
Vector DEN contains the coefficients of the denominator in descending powers of s. The numerator coefficients are returned in matrix NUM with as many rows as there are outputs y. Thus the above answer from MATLAB can be written as:
|© T. Nguyen MMIII, MMIV, MMV. All rights reserved. Republication or redistribution of the content in this site, including by framing or similar means, is expressly prohibited without the prior written consent of the author.|