# Fundamentals of Linear Control

Mauricio de Oliveira

Supplemental material for Chapter 3

## Before You Start

In this script you will perform calculations associated with rational functions. In addition to the commands already used, the following MATLAB commands will be used:

- laplace and ilaplace, to calculate (symbolic) Laplace transforms;
- residue, to calculate a partial-fraction expansion;

You will also use the following auxiliary commands:

- dirac and heaviside, to represent (symbolic) impulse and step functions.

## 3.1 The Laplace Transform

You can use the symbolic toolbox to calculate Laplace transforms in MATLAB. For example:

syms t s % t and s are now a symbolic variables

f = exp(-t) * cos(2 * t);

F = laplace(f, t, s)

You can also calculate the inverse Laplace transform:

ilaplace(F, s, t)

Impulses:

laplace(dirac(t), t, s)

and steps:

laplace(heaviside(t), t, s)

are fine. MATLAB also knows many of the properties and tricks you also know:

F = exp(-s)/(s + 1)

ilaplace(F, s, t)

## 3.5 Rational Functions

Standard MATLAB (not the symbolic toolbox) have a number of functions specialized to polynomial and rational functions. Polynomials are represented by their coefficients. The vectors:

num = [2]

den = [1 2 2]

can be used to represent the numerator and denominator of the rational function:

which is our example at the end of Section 3.5.

For example:

[r,p,k] = residue(num, den)

calculates its partial-fraction expansion. r contain the residues and p the correponding poles. In this case this partial-fraction leads to the inverse Laplace transform:

as show in Section 3.5. The output parameter k contains the remaining polynomial when is not strictly proper. For example, for

num = [1 -1]

den = [1 1]

[r,p,k] = residue(num, den)

has a non-zero polynomial remainder .

For another example, calculate the closed-loop response of the linear car model to a ramp target velocity with slope mph/s done in Section 3.5. Define the parameters:

% Linearized car model

pOverBHat = 73.3;

bOverMHat = 0.05;

pOverMHat = pOverBHat * bOverMHat;

For a given

k = 0.02

calculate the coefficients

a1 = bOverMHat + k * pOverMHat

b1 = k * pOverMHat

The close-loop response to a ramp of slope is the inverse Laplace transform of the transfer-function:

which can be calculated using residues as in:

mu = 12

num = mu * b1

den = [1 a1 0 0]

[r,p,k] = residue(num, den)

which can be used to construct the response

T = 15;

t = linspace(0,T,100);

y = r(1) * exp(p(1) * t) + r(2) * exp(p(2) * t) + r(3) * exp(p(3) * t) .* t;

Plot the response:

plot(t, y)

xlabel('t (s)')

ylabel('y(t) (mph)')

grid on

Calculate the closed-loop response and the steady-state part of the response of the linear car model to a ramp target velocity with slope mph/s for various values of gain:

yBar = 60

N = 4;

ks = [0 0.02 0.05 0.5];

yy = zeros(2*(N-1), length(t));

for i = 2 : N

k = ks(i);

b1 = k * pOverMHat;

a1 = bOverMHat + k * pOverMHat;

% response using residues

num = mu * b1;

den = [1 a1 0 0];

[r,p,k] = residue(num, den);

yy(i-1,:) = r(1) * exp(p(1) * t) + r(2) * exp(p(2) * t) + r(3) * exp(p(3) * t) .* t;

% steady-state response:

yy(N+i-2,:) = r(2) * exp(p(2) * t) + r(3) * exp(p(3) * t) .* t;

end

and plot the responses:

% Fig. 3.3:

figure()

plot([0 T], [0 mu*T], 'k--', t, yy, '-')

xlabel('t (s)')

ylabel('y(t) (mph)')

leg = [char(ones(N, 1) * double('K = ')) num2str(ks','%3.2f') char(ones(N, 1) * double(' '))];

leg(1,:) = 'reference';

legend(leg,'Location','NorthWest')

ylim([0 150]);

grid