You are on page 1of 18

1

TRANSFER FUNCTION
http://www.me.cmu.edu/ctms/modeling/tutorial/transferfunction/mainframes.htm
The modeling equation gathered from the free body diagram is in the time domain. Some analysis is easier to perform in the frequency domain. In order to convert to the frequency domain, apply the Laplace Transform to determine the transfer function of the system. The Laplace Transform converts linear differential equations into algebraic expressions which are easier to manipulate. The Laplace Transform converts functions with a real dependent variable (such as time) into functions with a complex dependent variable (such as frequency, often represented by s). The transfer function is the ratio of the output Laplace Transform to the input Laplace Transform assuming zero initial conditions. Many important characteristics of dynamic or control systems can be determined from the transfer function. The general procedure to find the transfer function of a linear differential equation from input to output is to take the Laplace Transforms of both sides assuming zero conditions, and to solve for the ratio of the output Laplace over the input Laplace.

HOW TO FIND THE TRANSFER FUNCTION


In most cases the governing equation will be linear, consisting of a variable and its derivatives. The Laplace Transform allows a linear equation to be converted into a polynomial. The most useful property of the Laplace Transform for finding the transfer function is the differentiation theorem. Several properties are shown below:

Time Domain Linearity Function 1st Derivative 2nd Derivative nth Derivative f(t) + g(t) x(t) x'(t) x"(t) xn(t)

Frequency Domain ( ) ( ) ( ) ( ) ( ) ( )
( ) (

( )

( ) ( )
)

( )

Note: While linearity allows Laplace Transforms to be added, the same does not hold true for multiplication. f(t)g(t) does not equal F(s)G(s). The solution to multiplication requires convolution, please refer to a differential equations book. In order to convert the time dependent governing equation to the frequency domain, perform the Laplace Transform to the input and output functions and their derivatives. These transformed functions must then be substituted back into the governing equation assuming zero initial conditions. Because the transfer function is defined as the output Laplace function over the input Laplace function, rearrange the equation to fit this form.

2
EXAMPLE Find the transfer function of the second order tutorial example problem: From the free body diagram we were able to extract the following governing equation:

f(t) - kx - bx' - mx" = 0


The notation of the Laplace Transform operation is L{ }. When finding the transfer function, zero initial conditions must be assumed, so x(0) = x'(0) = 0. Taking the Laplace Transform of the governing equation results in:

F(s) - k[X(s)] - b[sX(s)] - m[s2X(s)] = 0


Collecting all the terms involving X(s) and factoring leads to:

[ms2 + bs + k] X(s) = F(s)


The transfer function is defined as the output Laplace Transform over the input Laplace Transform, and so the transfer function of this second order system is:

X(s)/F(s) = 1/[ms2 + bs + k]

HOW TO INPUT THE TRANSFER FUNCTION INTO MATLAB


In order to enter a transfer function into MATLAB, the variables much be given numerical value, because MATLAB cannot manipulate symbolic variables without the symbolic toolbox. Enter the numerator and denominator polynomial coefficients separately as vectors of coefficients of the individual polynomials in descending order. The syntax for defining a transfer function in MATLAB is:

transferfunction = tf(num, den)


where num is defined as the vector of numerator coefficients, and den is defined as the vector of denominator coefficients.

EXAMPLE
Input the transfer function X(s)/F(s) = 1/[ms2 + bs + k] into MATLAB: For illustration purposes, this example uses m = 2, b = 5, and k = 3.

>> >> >> >> >> >>

m = 2; b = 5; k = 3; num = [ 1 ]; den = [ m b k ]; tutorial_tf = tf(num, den)

3
MATLAB will assign the transfer function under the name tutorial_tf, and output the following: Transfer function: 1 --------------2 s^2 + 5 s + 3

STEP RESPONSE USING THE TRANSFER FUNCTION


Once the transfer function is entered into MATLAB it is easy to calculate the response to a step input. To calculate the response to a unit step input, use:

step(transferfunction)
where transferfunction is the name of the transfer function of the system. For steps with magnitude other than one, calculate the step response using:

step(u * transferfunction)
where u is the magnitude of the step and transferfunction is the name of the transfer function of the system.

EXAMPLE
Find the unit step response and the step response when u = 4 of tutorial_tf using MATLAB: To find the unit step response:

>> step(tutorial_tf)
The MATLAB output will be the following plot of the unit step response:

To find the step response when u = 4:

>> u = 4; >> step(u * tutorial_tf)


The MATLAB output will be the following plot of the step response:

IMPULSE RESPONSE USING THE TRANSFER FUNCTION


MATLAB can also plot the impulse response of a transfer function. Because the transfer function is in the form of output over input, the transfer function must be multiplied by the magnitude of the impulse. The syntax for plotting the impulse response is:

impulse(u * transferfunction)
where u is the magnitude of the impulse and transferfunction is the name of the transfer function of the system.

EXAMPLE
Find the impulse response of tutorial_tf with an input of u = 2 using MATLAB:

>> u = 2; >> impulse(u * tutorial_tf)


The MATLAB output will be the following plot of the impulse response:

BODE PLOT USING THE TRANSFER FUNCTION


MATLABs bode command plots the frequency response of a system as a bode plot. The syntax for the bode plot function in MATLAB is:

bode(transferfunction)
where transferfunction is the name of the transfer function system.

EXAMPLE
Find bode plot of the frequency response of the system tutorial_tf using MATLAB:

>> bode(tutorial_tf)
The MATLAB output will be the following bode plot of the frequency response:

STATE SPACE FROM TRANSFER FUNCTION


MATLAB can find the state space representation directly from the transfer function in two ways. To find the state space representation of the system from the numerator and denominator of the transfer function in the form

x' = Ax + Bu y = Cx + Du
use MATLAB's tf2ss command:

[A, B, C, D] = tf2ss(num,den)
where num is the vector of the numerator polynomial coefficients, and den is the vector of the denominator polynomial coefficients. In order to find the entire state space system in addition to the separate matrices from the transfer function, use the following command:

7 statespace = ss(transferfunction)
where transferfunction is the name of the transfer function system.

EXAMPLE
Find A, B, C, and D, the state space vectors of tutorial_tf using MATLAB:

>> [A, B, C, D] = tf2ss(num,den)


The MATLAB output will be: A = -2.5000 1.0000 B = 1 0 C = 0 D = 0 Find the state space system of tutorial_tf using MATLAB: 0.5000 -1.5000 0

>> tutorial_ss = ss(tutorial_tf)


MATLAB will assign the state space system under the name tutorial_ss, and output the following: a = x1 x2 b = x1 x2 c = y1 x1 0 x2 0.5 u1 0.25 0 x1 -2.5 4 x2 -0.375 0

d = y1 u1 0

Continuous-time model.
http://antiguo.itson.mx/die/jmurrieta/cursos/se%C3%B1alesysistemas/tutorial%20Laplace-matlab.pdf http://www.seas.upenn.edu/~ese216/handouts/Chpt13LaplaceTransformsMATLAB.pdf

Tutorial de Matlab (1ra Parte)


Operaciones bsicas del anlisis matemtico
Derivadas: Para realizar derivadas utilizando MatLab usaremos el comando diff. >> diff('x^2') ans = 2x >> diff ('x^2',2) "Calculo de la 2da derivada" ans = 2 Para el calcular, 2da derivada, 3ra deriva hasta n derivada el comando ser: diff(' ',n).

Integrales: Para realizar calculo integral usaremos el comando int.


Integrales Indefinidas >> int('2x') ans = x^2 Integrales Definidas >> int('x',1,3) ans = 4 Transformada de Laplace: Para realizar transformadas de Laplace tenemos que usar variable simblicas. >> syms x t s w >> laplace (sin(3*t)) ans = 3/s^2+9

Calculo de races de un polinomio: Para realizar clculo de races de cualquier polinomio usaremos el comando roots de la siguiente manera:
Sea el polinomio x^2 -5x +6=0, calcular las races del mismo. 1ro. Tomamos los coeficientes del polinomio: 1 -5 6 2do. Utilizamos el comando roots >> roots([1 -5 6]) ans = x= -3 x= -2 Nota: Al introducir los coeficientes dentro del comando, los separamos con un espacio.

Creacin de un polinomio a partir de sus races: Para crear un polinomio a partir de


sus races usaremos el comando poly de la siguiente manera:

Usando las races del polinomio anterior.

9
>> poly([-3 -2]) ans = x^2-5x+6

Tutorial de MATLAB II Parte (Transformada de Laplace)


La Transformada de Laplace de una funcin f(t) para todos los nmeros reales mayores o iguales al cero es la funcin F(s) definida por:

( )

[ ( )]

( )

Esta transformada integral tiene una serie de propiedades que la hacen til en el anlisis de sistemas lineales. Una de las ventajas ms significativas radica en que la integracin y derivacin se convierten en multiplicacin y divisin. Esto transforma las ecuaciones diferenciales e integrales en ecuaciones polinmicas, mucho ms fciles de resolver. Es importante recordar que para el uso de la Transformada de Laplace en MatLab se necesitar trabajar con variables simblicas. A travs de MatLab podemos realizar el calculo este tipo de transformada de una manera muy sencilla. Los comandos a utilizar son los siguientes:

laplace( ) : Comando para realizar Transformadas de Laplace.


>> laplace(sin(t)) ans=1/(s^2+1)

ilaplace( ) : Comando para realizar la Transformada Inversa de Laplace


>> ilaplace(1/s(s^2+1)) ans=sin(t)

dirac( ) : Comando para realizar Transformadas de Laplace cuya f(t) tiene como argumento una funcin impulso o Delta de Dirac.
>> laplace(dirac(t)) ans=1

heaviside( ) : Comando para realizar Transformadas de Laplace cuya f(t) tiene como argumento una funcin escaln.
>> laplace(heaviside(t-5)) ans=exp(-5*s)/s Es importante recordar que para el uso de la Transformada de Laplace en MatLab se necesitar trabajar con variables simblicas. Ejercicio

( )

10
1er Metodo. Desarrollando toda la expresin y aplicar la propiedad de Linealidad a la expresin. >>laplace(4*t*heaviside(t))-laplace(4*t*heaviside(t-1))+laplace((5-t)* heaviside(t-1))-laplace((5-t)*heaviside(t-5)) ans= 4/s^2-5*exp(-s)/s^2 + exp(-5*s)/s^2 2do Metodo. Aplicando Transformada de Laplace a toda la expresin directamente si desarrollarla. >> laplace(4*t*(heaviside(t)-heaviside(t-1))+(5-t)*(heaviside(t-1)heaviside(t-5))) ans= 4/s^2-5*exp(-s)/(s^2+exp(-5*s)/s^2

LAPLACE TRANSFORM
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.

11 ( ) ( )

Examples
Laplace Transform MATLAB Command

( ) [ ] ( )

>> 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) >> syms t a x; >> f = exp(-a*t); >> laplace(f,x) returns ans = 1/(a + x)

( ) [ ( ) [

]( ) ( )

]( )

( )

INVERSE LAPLACE TRANSFORM ilaplace 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 F 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

12

( )

( )

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

( ) [ ] =t ( ) ( ] ) ( ) ( )

>> syms s; >> f = 1/s^2; >> ilaplace(f) returns ans = t >> syms a t; >> g = 1/(t-a)^2; >> ilaplace(g) 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

( )

[ ] ( )

( )

Example 1. Find the Laplace transform of

13 ( )
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): >> f=5*exp(-2*t); Finally, enter the following command: >> L=laplace(f) Matlab yields the following answer: L= 5/(s+2)

Example 2.
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.

Example 3.
Find the inverse Laplace transform of

( )

In Matlab Command window: >> ilaplace(1/s-2/(s+4)+1/(s+5))

14
Matlab result: ans = 1-2*exp(-4*t)+exp(-5*t) or

( )

) ( )

which is the solution of the differential equation

( )
As an exercise, you should carry out 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.

ZP2TF

Zero-pole to transfer function conversion.

[NUM,DEN] = ZP2TF(Z,P,K) forms the transfer function: ( ) ( ) ( )

given a set of zero locations in vector Z, a set of pole locations in vector P, and a gain in scalar K. Vectors NUM and DEN are returned with numerator and denominator coefficients in descending powers of s. TF2ZP Transfer function to zero-pole conversion.

[Z,P,K] = TF2ZP(NUM,DEN) finds the zeros, poles, and gains: ( ) ( ( )( )( ) ) ( ( ) )

from a SIMO transfer function in polynomial form: ( ) ( ) ( )

Vector DEN specifies the coefficients of the denominator in descending powers of s. Matrix NUM indicates the numerator coefficients with as many rows as there are outputs. The zero locations are returned in the columns of matrix Z, with as many columns as there are rows in NUM. The pole locations are returned in column vector P, and the gains for each numerator transfer function in vector K.

15
For discrete-time transfer functions, it is highly recommended to make the length of the numerator and denominator equal to ensure correct results. You can do this using the function EQTFLENGTH in the Signal Processing Toolbox. However, this function only handles single-input single-output systems. RESIDUE Partial-fraction expansion (residues).

[R,P,K] = RESIDUE(B,A) finds the residues, poles and direct term of a partial fraction expansion of the ratio of two polynomials B(s)/A(s). If there are no multiple roots, ( ) ( ) ( ) ( ) ( ) ( ) ( )

Vectors B and A specify the coefficients of the numerator and denominator polynomials in descending powers of s. The residues are returned in the column vector R, the pole locations in column vector P, and the direct terms in row vector K. The number of poles is n = length(A)-1 = length(R) = length(P). The direct term coefficient vector is empty if length(B) < length(A), otherwise length(K) = length(B)-length(A)+1. If P(j) = ... = P(j+m-1) is a pole of multiplicity m, then the expansion includes terms of the form () ( ) ( ) () ( ( () ( )) [B,A] = RESIDUE(R,P,K), with 3 input arguments and 2 output arguments, converts the partial fraction expansion back to the polynomials with coefficients in B and A. Warning: Numerically, the partial fraction expansion of a ratio of polynomials represents an ill-posed problem. If the denominator polynomial, A(s), is near a polynomial with multiple roots, then small changes in the data, including roundoff errors, can make arbitrarily large changes in the resulting poles and residues. Problem formulations making use of state-space or zero-pole representations are preferable. Class support for inputs B,A,R: float: double, single

16

17

18