The modeling equation gathered from the free body diagram is in the time domain.  We will now learn how to convert it into the frequency domain by performing the Laplace Transform and determining the transfer function of this first order system. 

In this example we will once again consider a truck pulling a trailer where the friction and wind resistance acts as a velocity dependant force, with a coefficient b. 

HOW TO FIND THE TRANSFER FUNCTION

From the free body diagram we were able to extract the following governing equation:

f(t) - m v' - b v = 0 

The notation of the Laplace Transform is L{ }

L{ v(t) } = V(s)

L{ v’(t) } = sV(s) – v(0)

L{ f(t) } = F(s)

 When finding the transfer function, ‘zero’ initial conditions must be assumed, so v(0) = 0.

 Substituting into the governing equation we get:

 m[sV(s)] + b[V(s)] – F(s) = 0

Rearranging we get:

[ms + b]V(s) = F(s)

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

 V(s)/F(s) = 1/[ms+b]

 

HOW TO INPUT THE TRANSFER FUNCTION INTO MATLAB

We will now enter this transfer function into MATLAB.  Because MATLAB cannot manipulate symbolic variables, we will now assign numerical values to each variable. 

m = 20,000kg

b = 500kg/s

>> m = 20000;

>> b = 500;

 

In order to enter the transfer function into MATLAB, you must separate the numerator and denominator, which in this example are denoted by ‘num’ and ‘den’ respectively.  The format for either matrix is to enter the coefficients of sn in descending order. 

>> num = [ 1 ];

>> den = [ m  b ];

>> first_tf = tf(num, den)

This will assign first_tf as the name of the transfer function as well as yield the following output:

 Transfer function:
       1
 -------------
 20000 s + 500

 

STEP RESPONSE USING THE TRANSFER FUNCTION

Now that we have the transfer function entered into MATLAB we can use MATLAB to do many useful calculations including determining the step response.  Because the transfer function is in the form of output over input and we are interested in finding the output, the transfer function must be multiplied by the input function.  In this case we will plot the unit step response, taking the input to be 1 unit.  This models what would happen if you applied 1N of force pushing this truck.

>> u = 1;

>> step(u * first_tf)

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

Obviously this truck is able to exert far more than 1N of force, which is why the truck moves so little.  More realistically this truck should be able to exert around 20,000N of force.

>> u = 20,000;

>> step(u * first_tf)

 

This is far more like it.  Given the truck is able to exert 20,000N of force, this truck, on level ground, has a top speed of 40m/s and takes 250s to reach that speed.  

IMPULSE RESPONSE USING THE TRANSFER FUNCTION 

MATLAB can also plot the impulse response of a transfer function.

>>  u = 1; 

>> impulse(u * first_tf)

 

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

 

Now given an input impulse of 20,000N:

>> u = 20000; 

>> impulse(u * first_tf)

 

This shows that given an impulse of 20,000N, the speed of the truck drops from 1m/s and takes approximately 250s to come to rest. 

BODE PLOT USING THE TRANSFER FUNCTION

MATLAB’s bode command plots the frequency response of a system as a bode plot.

>> bode(first_tf)

The MATLAB output will be the following bode plot of the frequency response:

While trucks are rarely tested in this way, this plot shows the response of this truck with a sinusoidal application of the throttle.  

STATE SPACE FROM TRANSFER FUNCTION

In the next section of this example problem we will learn how to determine the state-space representation of this first order system.  To find a state space representation of the system from the transfer function in the form

x' = Ax + Bu

y = Cx + Du

use MATLAB's tf2ss command:

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

The MATLAB output will be:

A =

    -0.0250 

B =

     1

C =

     5.0000e-005

D =

     0

 

In order to find the entire state space system instead of the separate matrices from the transfer function, use the following command:

>> first_ss = ss(first_tf)

MATLAB will assign the state space system under the name first_ss, and output the following:

a =

                        x1

           x1       -0.025

 

b =

                        u1

           x1     0.007813

 

c =

                        x1

           y1       0.0064

 

d =

                        u1

           y1            0

 

Continuous-time model.

Carnegie Mellon University | University of Michigan

Mechanical Engineering Department