Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

Lab 9

Laplace Transform & Plotting Functions

Objective

Learn how to compute Laplace transform

Laplace Transform

Laplace transform of a function f (t) is defined as

where

Laplace transform of a function f(t) can be obtained with Matlab's function laplace.

laplace

Laplace transform

Syntax

laplace(F)

laplace(F, t)

laplace(F, w, z)

Description:
L = laplace(F) computes the Laplace transform of the symbolic expression F. This syntax
assumes that F is a function of the variable t, and the returned value L as a function of s.

If F = F(s), laplace returns a function of t.


L = L(t)

By definition, the Laplace transform is

L = laplace(F,t) computes the Laplace transform L as a function of t instead of the default


variable s.

L = laplace(F,w,z) computes the Laplace transform L and lets you specify that L is a function
of z and F is a function of w.

Examples

Laplace Transform MATLAB Command

f(t) = t4
syms t;

f = t^4;

laplace(f)

returns

ans =
Laplace Transform MATLAB Command

24/s^5

syms s;

g = 1/sqrt(s);

laplace(g)

returns

ans =

pi^(1/2)/t^(1/2)

f(t) = e–at
syms t a x;

f = exp(-a*t);

laplace(f,x)

returns

ans =

1/(a + x)

2. Inverse Laplace Transform

ilaplace

Inverse Laplace transform


Syntax

F = ilaplace(L)
F = ilaplace(L,y)
F = ilaplace(L,y,x)

Description

F = ilaplace(L) computes the inverse Laplace transform of the symbolic expression L. This
syntax assumes that L is a function of the variable s, and the returned valueF is a function of t.

If L = L(t), ilaplace returns a function of x.


F = F(x)

By definition, the inverse Laplace transform is

where c is a real number selected so that all singularities of L(s) are to the left of the line s = c, i.
F = ilaplace(L,y) computes the inverse Laplace transform F as a function of y instead of the
default variable t.

F = ilaplace(L,y,x) computes the inverse Laplace transform and lets you specify that F is a
function of x and L is a function of y.

Examples
Inverse Laplace Transform MATLAB Command

syms s;

f = 1/s^2;

ilaplace(f)
=t
returns

ans =

syms a t;

g = 1/(t-a)^2;

ilaplace(g)
= xeax
returns

ans =

x*exp(a*x)

syms x u;

syms a real;

f = 1/(u^2-a^2);

simplify(ilaplace(f,x))

returns

ans =

sinh(a*x)/a

3. Plotting and Graphics


MATLAB offers fairly decent scientific visualization and graphics capabilities. In the current
version, MATLAB features both 2-D and 3-D graphics options. Some basic plotting and graphic
features are presented and discussed in this tutorial through a series of examples.

Example 1:

We wish to plot the function:

for the range of t from 0 to 5 with an increment of .1.

In MATLAB Command window, enter the following lines:

Please note that the array representing the function y must have the same dimension as that
of t array. Array division "./" and array exponential ".^" are used to create the y array as a
function of t.Note that MATLAB will treat all entries after the "%" sign as comment line. The
command "gtext" is used to insert a user-defined text string at a chosen cursor position on the
graph. The graphic window displaying the plot is shown below:
Example 2:

Two or more plots can be shown on the same graph as shown in this example. In this example, an
additional function "y2" is to be shown with function y plotted in Example 1 on the same graph.
Note that the "legend" function is used to label the plots. The entries in MATLAB command
window are as follows:

The resulting plot is shown below:


Note that markers are used in the "plot" function in Example 2 for the purpose of identification.
The table below lists all markers offered in MATLAB.

Designated Used in "plot" Designated Used in "plot"


color command line style command
yellow Y point .
red R circle o
green G x-mark x
blue B plus +
black K star *
white W solid - (minus sign)
magenta M dotted :
cyan C dash dotted -.
dashed -- (two minus signs)

Example 3:
You may show multiple plot in an array format. This can be achieved with the "subplot" command.
You may arrange multiple plot in any array you wish, e.g., a 2 x 2 plot array would yield two plots
on the top row and two plots on the bottom row. The functions used in Examples 1 and 2 above
can be shown in an array format by the following inputs:

which, will produce these graphs in one plot:

Example 4:

Find the Laplace transform of:


In MATLAB Command Window:

>> laplace(12*diff(sym('y(t)'),2))

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).

MATLAB result:

ans=12*s*(s*laplace(y(t),t,s)-y(0))-12*D(y)(0)

where y(0) is the initial condition.

Post lab task

Read the instructions and evaluate the following by hand and through MATLAB:

1. Find the Laplace transform of


2. Find the Laplace transform of:
3. Find the inverse Laplace transform of
4. Plot all functions in time- domain
5. Don’t forget to submit a Lab Report discussing whatever you have understood in this lab
manual and your findings
6. Attach the printed form of MATLAB code and figures

CONCLUSION:

In this part(a) session of the lab, I learned about laplace transform and it’s uses. Laplace
transform of a function f (t) is defined as

The Laplace transform is also used for solving differential equations. It is accepted widely in many
fields. We also know that Laplace transform simplifies a given LDE (linear differential equation) to
an algebraic equation, which can later be solved using the standard algebraic identities.
In general, the Laplace transform is used for the applications in the time-domain for t ≥ 0. However,
the transformation variable must not necessarily be time. It can also be any independent variable x
on the domain from 0 to ∞.
Laplace transform is the integral transform of the given derivative function with real variable t to
convert into a complex function with variable s. For t ≥ 0, let f(t) be given and assume the function
satisfies certain conditions to be stated later on. Whenever the improper integral converges.
Laplace transform is an integral transform method which is particularly useful in solving linear
ordinary differential equations. It finds very wide applications in various areas of physics, electrical
engineering, control engineering, optics, mathematics and signal processing.
I also performed laplace and inverse laplace transform on matlab software and calculated the results
of the equations as shown above.
Part (b)

Transfer Functions

Partial Fraction Expansion:

Residue finds the partial fraction expansion of the ratio of two polynomials. This is particularly
useful for applications that represent systems in transfer function form. For polynomials b and a,
if there are no multiple roots,

where r is a column vector of residues, p is a column vector of pole locations, and k is a row
vector of direct terms. Consider the transfer function

b = [-4 8];

a = [1 6 8];

[r,p,k] = residue(b,a)

r=

-12

p=

-4

-2
k=

[]

Given three input arguments (r, p, and k), residue converts back to polynomial form:

[b2,a2] = residue(r,p,k)

b2 =

-4 8

a2 =

1 6 8

Convolution:
conv -Convolution and polynomial multiplication

Syntax

w = conv(u,v)
w = conv(...,'shape')

Description:

w = conv(u,v) convolves vectors u and v. Algebraically, convolution is the same operation as


multiplying the polynomials whose coefficients are the elements of uand v.
w = conv(...,'shape') returns a subsection of the convolution, as specified by the shape parameter:
full
Returns the full convolution (default).

same Returns the central part of the convolution of the same size as u.

valid Returns only those parts of the convolution that are computed without the zero-padded
edges. Using this option,length(w) is max(length(u)-max(0,length(v)-1),0).
Definitions:

Let m = length(u) and n = length(v) . Then w is the vector of length m+n-1 whose kth element is

The sum is over all the values of j which lead to legal subscripts for u(j) and v(k+1-j),
specifically j = max(1,k+1-n): min(k,m). When m = n, this gives

w(1) = u(1)*v(1)

w(2) = u(1)*v(2)+u(2)*v(1)

w(3) = u(1)*v(3)+u(2)*v(2)+u(3)*v(1)

...

w(n) = u(1)*v(n)+u(2)*v(n-1)+ ... +u(n)*v(1)

...

w(2*n-1) = u(n)*v(n)

Transfer Function

tf -Create transfer function model, convert to transfer function model

Syntax

tf
sys = tf(num,den)
sys = tf(num,den,Ts)
sys = tf(M)
sys = tf(num,den,ltisys)
tfsys = tf(sys)
Description:

Use tf to create real- or complex-valued transfer function models (TF objects) or to convert state-
space or zero-pole-gain models to transfer function form. You can also use tf to create Generalized
state-space (genss) models.

Creation of Transfer Functions:


sys = tf(num,den) creates a continuous-time transfer function with numerator(s) and
denominator(s) specified by num and den. The output sys is a TF object storing the transfer
function data.

In the SISO case, num and den are the real- or complex-valued row vectors of numerator and
denominator coefficients ordered in descending powers of s. These two vectors need not have
equal length and the transfer function need not be proper. For example, h = tf([1 0],1) specifies the
pure derivative h(s) = s.
To create MIMO transfer functions, using one of the following approaches:

 Concatenate SISO tf models.


 Use the tf command with cell array arguments. In this case, num and den are cell arrays
of row vectors with as many rows as outputs and as many columns as inputs. The row
vectors num{i,j} and den{i,j} specify the numerator and denominator of the transfer
function from input j to output i.

For examples of creating MIMO transfer functions, see Examples and Multi-Input, Multi-Output
Transfer Function Model in the Control System Toolbox User Guide.

If all SISO entries of a MIMO transfer function have the same denominator, you can set den to
the row vector representation of this common denominator. See "Examples" for more details.

sys = tf(num,den,Ts) creates a discrete-time transfer function with sample time Ts (in seconds).
Set Ts = -1 to leave the sample time unspecified. The input arguments num and den are as in the
continuous-time case and must list the numerator and denominator coefficients
in descending powers of z.

sys = tf(M) creates a static gain M (scalar or matrix).


sys = tf(num,den,ltisys) creates a transfer function with properties inherited from the dynamic
system
model ltisys (including the sample time).

There are several ways to create arrays of transfer functions. To create arrays of SISO or MIMO
TF models, either specify the numerator and denominator of each SISO entry using
multidimensional cell arrays, or use a for loop to successively assign each TF model in the array.
See Model Arrays in the Control System Toolbox User Guide for more information.

Any of the previous syntaxes can be followed by property name/property value pairs

'Property',Value

Each pair specifies a particular property of the model, for example, the input names or the
transfer function variable. For information about the properties of tfobjects, see Properties. Note
that

sys = tf(num,den,'Property1',Value1,...,'PropertyN',ValueN)

is a shortcut for

sys = tf(num,den)

set(sys,'Property1',Value1,...,'PropertyN',ValueN)

Read the instructions and evaluate the following by hand and through MATLAB:

Evaluate the partial fraction for following functions:

3s−2
1.
s2−s
s2+9s−9
2.
s3−9s
CONCLUSION:
In this part(b) session of the lab, I learned about transfer functions and learned about partial
fractions and how to find it on matlab software.
Partial Fraction Expansion:
Residue finds the partial fraction expansion of the ratio of two polynomials. This is particularly
useful for applications that represent systems in transfer function form.
For polynomials b and a, if there are no multiple roots, where r is a column vector of residues, p is a
column vector of pole locations, and k is a row vector of direct terms. It’s method is as follows:
b = [-4 8];
a = [1 6 8];
[r,p,k] = residue(b,a)
Partial fractions are the fractions used for the decomposition of a rational expression. When an
algebraic expression is split into a sum of two or more rational expressions, then each part is called a
partial fraction. Hence, basically, it is the reverse of the addition of rational expressions .
Partial-fraction decomposition is the process of starting with the simplified answer and taking it back
apart, of "decomposing" the final expression into its initial polynomial fractions. To decompose a
fraction, you first factor the denominator.
In this way by using the above method we can calculate the partial fraction of the above given
questions. Hence, result’s can be verified.

You might also like