0% found this document useful (0 votes)
60 views

Labno9: Laplace Transform & Plotting Functions Laplace Transform

This document discusses Laplace transforms, plotting functions, and transfer functions in MATLAB. It provides examples of using the laplace, ilaplace, plot, and tf commands. The laplace command computes the Laplace transform and ilaplace computes the inverse Laplace transform. The plot command graphs functions. The tf command creates transfer function models from numerators and denominators.

Uploaded by

Syed Waqas Shah
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

Labno9: Laplace Transform & Plotting Functions Laplace Transform

This document discusses Laplace transforms, plotting functions, and transfer functions in MATLAB. It provides examples of using the laplace, ilaplace, plot, and tf commands. The laplace command computes the Laplace transform and ilaplace computes the inverse Laplace transform. The plot command graphs functions. The tf command creates transfer function models from numerators and denominators.

Uploaded by

Syed Waqas Shah
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Lab no 9

Laplace Transform & Plotting Functions

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.

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

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

returns
= t
ans =
t

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

returns
= xeax
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

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.


 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"
colour command linestyle 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 dashdotted -.
    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:

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

Lab Report

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

Find the Laplace transform of

Find the inverse Laplace transform of


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
Given three input arguments (r, p, and k), residue converts back to polynomial form:

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

Convolution

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

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.

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)

Post lab task:

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

Evaluate the partial fraction for following functions:

3 s−2
1.
s 2−s

s 2+ 9 s−9
2. 3
s −9 s
11 s−14
3. 3 2
s −s −4 s+ 4

s
4.
( s+ 1 )2
s
5. 2
s + 2 s+2

10 ( s +1 )
6. 2
s ( s+ 4 ) ( s +6 )
Comment and Conclusion:

In this lab we learnt about the Laplace and inverse Laplace theorm. In Laplace transform of a
function f (t) can be obtained with Matlab's function ilaplace and F = ilaplace (L, y) computes
the inverse Laplace transform F as a function of y instead of the default variable t. we also
learn about the Plotting and Graphics. In this Matlab offers fairly decent scientific
visualization and graphics capabilities. In the current version, Matlab features both 2-D and
3-D graphics options. We also perform examples and lab tasks related to these experiments.
We also learn about the Partial Fraction Expansion, transfer function and convolution theorm.
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. Convolution is the same operation as multiplying the polynomials
whose coefficients are the elements of u and v.at the last we perform the tasks related to the
topics and calculate their results.

You might also like