Table Of Contents

Control System Toolbox

The control toolbox provides algorithms and tools for solving various problems in control system design. This includes analyzing linear systems and controller design. The linear systems can be defined in various formats such as transfer-function, state-space, pole-zero-gain, and frequency-response models. This section will describe elementary tools commonly used in control system analysis and design.

Continuous-time linear systems of order n can be described by a state-space equation

(1)\dot{x} = Ax + Bu, \quad y = Cx+Du

where x \in \mathbb{R}^n is state variable, y is the output, and u is the input of the system. Here we only consider a scalar input scalar output system (SISO), so y,u are scalar. The matrix A is n x n, B is n x 1, C is 1 x n and D is 1 x 1.

A linear system can also be expressed by a transfer function in s-domain. If we take the Laplace transform of (1) with zero initial condition x(0)=0, we have

sX(s) = AX(s)+BU(s) \quad \Longrightarrow \quad X(s) = (sI-A)^{-1} BU(s)

and

Y(s) = CX(s)+ DU(s) = C(sI-A)^{-1}BU(s) + DU(s)

Therefore, the transfer function from u to y is

(2)G(s) = \frac{Y(s)}{U(s)} = C(sI-A)^{-1}B + D \triangleq \frac{N(s)}{D(s)}

The expressions in (1) and (2) are the two typical representations of linear systems. We will show how to write dynamics of a system into these representations.

Consider the dynamic behavior of the liquid level in a manometer tube, responding to a change in pressure, which is given by

(3)\frac{d^2 h}{dt^2}  + a \frac{dh}{dt} + b h = p(t)

where h is the level of fluid measured with respect to the initial state value, p is the pressure change, and a,b are constants. To write the dynamic in a state-space format, first we define a state variable (which has two components since the ODE is 2nd-order)

x = \begin{bmatrix} x_1 \\ x_2 \end{bmatrix} = \begin{bmatrix} h \\ \dot{h} \end{bmatrix} \Longrightarrow \begin{bmatrix} \dot{x}_1 \\ \dot{x}_2 \end{bmatrix} = \begin{bmatrix} x_2 \\ -a x_2 - bx_1 + p \end{bmatrix}

We consider the pressure change u=p as an input and h as the output of the system (y = h = x_1). The state-space description of this system is

\dot{x} = \begin{bmatrix} 0 & 1 \\ -b & -a \end{bmatrix} x + \begin{bmatrix} 0 \\ 1 \end{bmatrix} u, \quad y = \begin{bmatrix} 1 & 0 \end{bmatrix}x

The transfer function from u to y is

\begin{eqnarray*}
G(s) &=& C(sI-A)^{-1}B + D = \begin{bmatrix} 1 & 0 \end{bmatrix} \begin{bmatrix} s & - 1\\b & s+a \end{bmatrix}^{-1}\begin{bmatrix} 0 \\ 1 \end{bmatrix} + 0 \\ &=& \frac{1}{s(s+a)+b}  \begin{bmatrix} 1 & 0 \end{bmatrix} \begin{bmatrix} s+a &  1\\ -b & s \end{bmatrix}^{-1}\begin{bmatrix} 0 \\ 1 \end{bmatrix} = \frac{1}{s^2+as+b}
\end{eqnarray*}

Of course, we can also obtain the transfer function directly by taking Laplace transform of (3).

s^2 H(s)+as H(s) + b H(s) = P(s) , \Longrightarrow (s^2+as+b) H(s) = P(s) \Longrightarrow G(s) = \frac{H(s)}{P(s)} = \frac{1}{s^2+as+b}

In what follows, we consider linear systems in either a state-space format (1) or a transfer function (2). Once we have a system description, we use the Control toolbox to create a system object, and analyze several properties of the system.

Creating LTI objects

Suppose the constants in example (?) are a = 3, b = 2, so the matrices (A,B,C,D) in the state-space format are

A = \begin{bmatrix} 0 & 1 \\ -2 & -3 \end{bmatrix} , \quad  B = \begin{bmatrix} 0 \\ 1 \end{bmatrix} ,\quad C = \begin{bmatrix} 1 & 0 \end{bmatrix}, \quad D = 0.

The transfer function is

G(s) = \frac{1}{s^2+3s+2}

State-space object

To create a system object in a state-space format, we use the command ss which has the form:

sys = ss(A,B,C,D)

where sys is a state-space object representing the continuous-time state-space model using parameters A,B,C,D. The system in (3) can be created by:

>> A=[0 1;-2 -3];B=[0 1]';C=[1 0];D = 0;
>> sys1 = ss(A,B,C,D)

a =
       x1  x2
   x1   0   1
   x2  -2  -3

b =
       u1
   x1   0
   x2   1

c =
       x1  x2
   y1   1   0

d =
       u1
   y1   0

Continuous-time model.

The variable sys1 has the class of ss object, as can be checked by typing:

>> whos sys1
  Name      Size            Bytes  Class    Attributes

  sys1      1x1              2141  ss

Transfer function

To create a system object in a transfer function format, we use the command tf which has the form:

sys = tf(num,den)

where num,den are the coefficient vectors of the polynomials in numerator and denomenator, respectively. The output sys is a transfer function (tf) object. With the same example, we create the transfer function of (3) by:

>> sys2 = tf([1],[1 3 2])

Transfer function:
      1
-------------
s^2 + 3 s + 2

>> whos sys2
  Name      Size            Bytes  Class    Attributes

  sys2      1x1              2370  tf

Zero-Pole-Gain object

Suppose a transfer function is described by the following format

G(s) = K \frac{(s-z_1)(s-z_2) \cdots (s-z_m)}{(s-p_1)(s-p_2)\cdots (s-p_n)}.

Zeros and poles of a system are defined as roots of the numerator and denominator, respectively. Therefore, z_k determines the location of zeros and p_k are the location of poles. With this representation, the system has gain K.

For example,

G(s) = \frac{10s(s+1)}{(s+1)((s+2)^2+1)}

The zeros of G(s) are 0 and -1 and poles of G(s) are -1, -2 \pm -j with gain 10. When it is more convenient to specify G(s) from the location of zeros and poles, we use the command zpk to create a system object, which has the form:

sys = zpk(z,p,k)

where z,p are vectors containing the location of zeros and poles, respectively, and k is the system gain. Using the above example, the system can be created by:

>> sys3 = zpk([0 -1],[-1 -2+i -2-i],10)

Zero/pole/gain:
     10 s (s+1)
--------------------
(s+1) (s^2 + 4s + 5)

>> whos sys3
  Name      Size            Bytes  Class    Attributes

  sys3      1x1              2528  zpk

Conversion between state-space and transfer function

  • tf2ss: Convert transfer function parameters to state-space form. The command has the form:

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

where num,den are polynomials in the numerator and denominator of H(s), respectively. It returns the A, B, C,D matrices of a state space representation.

  • ss2tf: Convert state-space parameters into transfer function form. The command:

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

returns num,den as the numerator and denominator of H(s) where A,B,C,D are matrices of the state-space equation.

Example

Consider a linear ODE

\dddot{y} + 4 \ddot{y} + 30 \ddot{y} + 52 y = 2 u

which can be expressed in state-space form as

\dot{x} = \begin{bmatrix} 0 & 1 & 0 \\ 0 & 0 & 1 \\ -52 & -30 & -4 \end{bmatrix} x + \begin{bmatrix} 0 \\ 0 \\ 2 \end{bmatrix} u , \quad y = \begin{bmatrix} 1 & 0 & 0 \end{bmatrix} x

The corresponding transfer function is

H(s) = \frac{2}{s^3 + 4 s^2 + 30 s + 52 }

First, let’s define the matrices of the state-space equation:

>> A=[0 1 0;0 0 1;-52 -30 -4]; B = [0 0 2]'; C = [1 0 0]; D = 0;

The transfer function can be obtained by:

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

num =
         0   -0.0000    0.0000    2.0000

den =
    1.0000    4.0000   30.0000   52.0000

which agrees with H(s) provided above. On the other hand, suppose we define the numerator and denominator of the transfer function as

>>  num = 2; den = [1 4 30 52];

then the system matrices in the state-space equation is obtained by:

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

A =
    -4   -30   -52
     1     0     0
     0     1     0

B =

     1
     0
     0

C =
     0     0     2

D =
     0

The result shows that the matrices A,B,C,D are different from those we have derived eariler. This is due to the fact that a state-space description of a system is NOT unique. These A,B,C,D correspond to a choice of state variable

x = \begin{bmatrix} \ddot{y} & \dot{y} & y \end{bmatrix}

Time-domain analysis

  • initial: Initial condition response (or zero-input response) of state-space model:

    initial(sys,x0,t)
    
_images/control_initial12.png

x0 is the initial state vector, t is a final time (or it could be a vector of time samples), and sys is a state-space object. For example, the initial condition response of the system

(4)\dot{x} = \begin{bmatrix} -1 & 2 \\ 0 & -2 \end{bmatrix} x + \begin{bmatrix} 0 \\ 1 \end{bmatrix} u, \quad y = \begin{bmatrix} 1 & 0 \end{bmatrix} x

where x(0) = \begin{bmatrix} -1 & 1 \end{bmatrix}^T from t=0 to t=10 is obtained by:

>> A = [-1 2;0 -2]; B = [0 1]'; C = [1 0];
>> sys = ss(A,B,C,0);
>> initial(sys,[-1 1]',10);
  • impulse: Impulse response of LTI model. We compute a solution of linear systems due to a unit impulse input (u(t) = \delta (t)) and zero initial condition (x(0)=0). The command has the form:

    impulse(sys,t)
    
_images/control_impulse11.png

where sys is an LTI object (state-space or transfer function) and t is a final time. For example, the impulse response of system (4) from t=0 to t=10 is obtained by:

>> impulse(sys,10);
  • step: Step response of LTI systems. We compute a solution of linear systems due to the unit step input (u(t) = 1, \forall t \geq 0) and zero initial condition (x(0)=0). The command has the form:

    step(sys,t)
    
_images/control_step12.png

where sys is an LTI object (state-space or transfer function) and t is a final time. For example, the step response of system (4) from t=0 to t=10 is obtained by:

>> step(sys,10);

  • lsim: Simulate LTI model responses to arbitrary inputs. The command format is:

    lsim(sys,u,t,x0)
    

The vector t specifies the time samples for the simulation and consists of regularly spaced time samples (for example t = 0:0.01:10). The vector u must have as many rows as time samples (length(t)). With the same system given earlier, we can compute the zero-input response (initial condition response) by:

>> t = 0:0.01:10;
>> u = zeros(1,length(t));
>> lsim(sys,u,t,[-1 1]);

The command produces a plot of the zero-input response and the plot must be identical to that of initial(sys,[-1 1]). Now suppose the input is the unit step function. The zero-state response (by setting the initial condition to zero) is done by:

>> u = ones(1,length(t));
>> lsim(sys,u,t,[0 0]);
_images/control_lsim12.png

The plot must be identical to that obtained from the command step(sys). Therefore, a response due to an arbitrary input and with a nonzero initial state can be obtained by

>> u = sin(t);
>> lsim(sys,u,t,[-1 1])

(In this example, the input has a sinusoidal wave form.)

Frequency-domain analysis