# Control Systems/System Metrics

## System Metrics

When a system is being designed and analyzed, it doesn\'t make any sense
to test the system with all manner of strange input functions, or to
measure all sorts of arbitrary performance metrics. Instead, it is in
everybody\'s best interest to test the system with a set of standard,
simple reference functions. Once the system is tested with the reference
functions, there are a number of different metrics that we can use to
determine the system performance.

It is worth noting that the metrics presented in this chapter represent
only a small number of possible metrics that can be used to evaluate a
given system. This wikibook will present other useful metrics along the
way, as their need becomes apparent.

## Standard Inputs

There are a number of standard inputs that are considered simple enough
and universal enough that they are considered when designing a system.
These inputs are known as a **unit step**, a **ramp**, and a
**parabolic** input.

Also, sinusoidal and exponential functions are considered basic, but
they are too difficult to use in initial analysis of a system.

## Steady State

When a unit-step function is input to a system, the **steady-state**
value of that system is the output value at time $t = \infty$. Since it
is impractical (if not completely impossible) to wait till infinity to
observe the system, approximations and mathematical calculations are
used to determine the steady-state value of the system. Most system
responses are **asymptotic**, that is that the response approaches a
particular value. Systems that are asymptotic are typically obvious from
viewing the graph of that response.

### Step Response

The step response of a system is most frequently used to analyze
systems, and there is a large amount of terminology involved with step
responses. When exposed to the step input, the system will initially
have an undesirable output period known as the **transient response**.
The transient response occurs because a system is approaching its final
output value. The steady-state response of the system is the response
after the transient response has ended.

The amount of time it takes for the system output to reach the desired
value (before the transient response has ended, typically) is known as
the **rise time**. The amount of time it takes for the transient
response to end and the steady-state response to begin is known as the
**settling time**.

It is common for a systems engineer to try and improve the step response
of a system. In general, it is desired for the transient response to be
reduced, the rise and settling times to be shorter, and the steady-state
to approach a particular desired \"reference\" output.

+----------------------------------+----------------------------------+
| ![](Step_Function.svg "          | ![](Step_Response.svg "          |
| Step_Function.svg"){width="400"} | Step_Response.svg"){width="400"} |
+----------------------------------+----------------------------------+
| ```{=html}                       | ```{=html}                       |
| <center>                         | <center>                         |
| ```                              | ```                              |
| An arbitrary step function with  | A step response graph of input   |
| $x(t) = Mu(t)$                   | *x(t)* to a made-up system       |
|                                  |                                  |
| ```{=html}                       | ```{=html}                       |
| </center>                        | </center>                        |
| ```                              | ```                              |
+----------------------------------+----------------------------------+

{{-}}

## Target Value

The target output value is the value that our system attempts to obtain
for a given input. This is not the same as the steady-state value, which
is the actual value that the system does obtain. The target value is
frequently referred to as the **reference value**, or the \"reference
function\" of the system. In essence, this is the value that we want the
system to produce. When we input a \"5\" into an elevator, we want the
output (the final position of the elevator) to be the fifth floor.
Pressing the \"5\" button is the reference input, and is the expected
value that we want to obtain. If we press the \"5\" button, and the
elevator goes to the third floor, then our elevator is poorly designed.

## Rise Time

**Rise time** is the amount of time that it takes for the system
response to reach the target value from an initial state of zero. Many
texts on the subject define the rise time as being the time it takes to
rise between the initial position and 80% of the target value. This is
because some systems never rise to 100% of the expected, target value,
and therefore they would have an infinite rise-time. This book will
specify which convention to use for each individual problem. Rise time
is typically denoted *t~r~*, or *t~rise~*.

## Percent Overshoot

Underdamped systems frequently overshoot their target value initially.
This initial surge is known as the \"overshoot value\". The ratio of the
amount of overshoot to the target steady-state value of the system is
known as the **percent overshoot**. Percent overshoot represents an
overcompensation of the system, and can output dangerously large output
signals that can damage a system. Percent overshoot is typically denoted
with the term *PO*.

## Steady-State Error

Sometimes a system might never achieve the desired steady-state value,
but instead will settle on an output value that is not desired. The
difference between the steady-state output value to the reference input
value at steady state is called the **steady-state error** of the
system. We will use the variable *e~ss~* to denote the steady-state
error of the system.

## Settling Time

After the initial rise time of the system, some systems will oscillate
and vibrate for an amount of time before the system output settles on
the final value. The amount of time it takes to reach steady state after
the initial rise time is known as the **settling time**. Notice that
damped oscillating systems may never settle completely, so we will
define settling time as being the amount of time for the system to
reach, and stay in, a certain acceptable range. The acceptable range for
settling time is typically determined on a per-problem basis, although
common values are 20%, 10%, or 5% of the target value. The settling time
will be denoted as *t~s~*.

## System Order

The **order** of the system is defined by the number of independent
energy storage elements in the system, and intuitively by the highest
order of the linear differential equation that describes the system. In
a transfer function representation, the order is the highest exponent in
the transfer function. In a **proper system**, the system order is
defined as the degree of the denominator polynomial. In a state-space
equation, the system order is the number of state-variables used in the
system. The order of a system will frequently be denoted with an *n* or
*N*, although these variables are also used for other purposes. This
book will make clear distinction on the use of these variables.

### Proper Systems

A **proper system** is a system where the degree of the denominator is
larger than or equal to the degree of the numerator polynomial. A
**strictly proper system** is a system where the degree of the
denominator polynomial is larger than (but never equal to) the degree of
the numerator polynomial. A **biproper system** is a system where the
degree of the denominator polynomial equals the degree of the numerator
polynomial.

It is important to note that only proper systems can be physically
realized. In other words, a system that is not proper cannot be built.
It makes no sense to spend a lot of time designing and analyzing
imaginary systems.

### Example: System Order

In the above example, G(s) is a second-order transfer function because
in the denominator one of the s variables has an exponent of 2.
Second-order functions are the easiest to work with.

## System Type

Let\'s say that we have a process transfer function (or combination of
functions, such as a controller feeding in to a process), all in the
forward branch of a unity feedback loop. Say that the overall forward
branch transfer function is in the following generalized form (known as
**pole-zero form**):

$$G(s) = \frac {K \prod_i (s - s_i)}{s^M \prod_j (s - s_j)}$$

we call the parameter *M* the **system type**. Note that increased
system type number correspond to larger numbers of poles at s = 0. More
poles at the origin generally have a beneficial effect on the system,
but they increase the order of the system, and make it increasingly
difficult to implement physically. System type will generally be denoted
with a letter like *N*, *M*, or *m*. Because these variables are
typically reused for other purposes, this book will make clear
distinction when they are employed.

Now, we will define a few terms that are commonly used when discussing
system type. These new terms are **Position Error**, **Velocity Error**,
and **Acceleration Error**. These names are throwbacks to physics terms
where acceleration is the derivative of velocity, and velocity is the
derivative of position. Note that none of these terms are meant to deal
with movement, however.

Position Error:The position error, denoted by the **position error constant** *$K_p$*. This is the amount of steady-state error of the system when stimulated by a unit step input. We define the position error constant as follows:

$$K_p = \lim_{s \to 0} G(s)$$

:   Where G(s) is the transfer function of our system.

```{=html}
<!-- -->
```

Velocity Error:The velocity error is the amount of steady-state error when the system is stimulated with a ramp input. We define the **velocity error constant** as such:

$$K_v = \lim_{s \to 0} s G(s)$$

Acceleration Error:The acceleration error is the amount of steady-state error when the system is stimulated with a parabolic input. We define the **acceleration error constant** to be:

$$K_a = \lim_{s \to 0} s^2 G(s)$$

Now, this table will show briefly the relationship between the system
type, the kind of input (step, ramp, parabolic), and the steady-state
error of the system:

:   {\| class=\"wikitable\"

! ! colspan=3 \| Unit System Input \|- ! Type, *M* !! *Au(t)* !! *Ar(t)*
!! *Ap(t)* \|- \|0 \|\| $e_{ss} = \frac{A}{1 + K_p}$ \|\|
$e_{ss} = \infty$ \|\| $e_{ss} = \infty$ \|- \|1 \|\| $e_{ss} = 0$ \|\|
$e_{ss} = \frac{A}{K_v}$ \|\| $e_{ss} = \infty$ \|- \|2 \|\|
$e_{ss} = 0$ \|\| $e_{ss} = 0$ \|\| $e_{ss} = \frac{A}{K_a}$ \|- \| \> 2
\|\| $e_{ss} = 0$ \|\| $e_{ss} = 0$ \|\| $e_{ss} = 0$ \|}

### Z-Domain Type

Likewise, we can show that the system order can be found from the
following generalized transfer function in the *Z* domain:

$$G(z) = \frac {K \prod_i (z - z_i)}{(z - 1)^M \prod_j (z - z_j)}$$

Where the constant *M* is the **type** of the digital system. Now, we
will show how to find the various error constants in the Z-Domain:

:   {\| class=\"wikitable\"

! Error Constant !! Equation \|- \| Kp \|\| $K_p = \lim_{z \to 1} G(z)$
\|- \| Kv \|\| $K_v = \lim_{z \to 1} (z - 1) G(z)$ \|- \| Ka \|\|
$K_a = \lim_{z \to 1} (z - 1)^2 G(z)$ \|}

## Visually

Here is an image of the various system metrics, acting on a system in
response to a step input:

![](System_Metrics_Diagram.svg "System_Metrics_Diagram.svg"){width="500"}

The target value is the value of the input step response. The rise time
is the time at which the waveform first reaches the target value. The
overshoot is the amount by which the waveform exceeds the target value.
The settling time is the time it takes for the system to settle into a
particular bounded region. This bounded region is denoted with two short
dotted lines above and below the target value.


# Control Systems/System Modeling

## The Control Process

It is the job of a control engineer to analyze existing systems, and to
design new systems to meet specific needs. Sometimes new systems need to
be designed, but more frequently a controller unit needs to be designed
to improve the performance of existing systems. When designing a system,
or implementing a controller to augment an existing system, we need to
follow some basic steps:

1.  Model the system mathematically
2.  Analyze the mathematical model
3.  Design system/controller
4.  Implement system/controller and test

The vast majority of this book is going to be focused on (2), the
analysis of the mathematical systems. This chapter alone will be devoted
to a discussion of the mathematical modeling of the systems.

## External Description

An **external description** of a system relates the system input to the
system output without explicitly taking into account the internal
workings of the system. The external description of a system is
sometimes also referred to as the **Input-Output Description** of the
system, because it only deals with the inputs and the outputs to the
system.

![](Time-Domain_Transfer_Block.svg "Time-Domain_Transfer_Block.svg")

If the system can be represented by a mathematical function *h(t, r)*,
where *t* is the time that the output is observed, and *r* is the time
that the input is applied. We can relate the system function *h(t, r)*
to the input *x* and the output *y* through the use of an integral:

$$y(t) = \int_{-\infty}^\infty h(t, r)x(r)dr$$

This integral form holds for all linear systems, and every linear system
can be described by such an equation.

If a system is causal (i.e. an input at *t=r* affects system behaviour
only for $t \ge r$) and there is no input of the system before *t=0*, we
can change the limits of the integration:

$$y(t) = \int_0^t h(t, r)x(r)dr$$

### Time-Invariant Systems

If furthermore a system is time-invariant, we can rewrite the system
description equation as follows:

$$y(t) = \int_0^t h(t - r)x(r)dr$$

This equation is known as the **convolution integral**, and we will
discuss it more in the next chapter.

Every Linear Time-Invariant (LTI) system can be used with the **Laplace
Transform**, a powerful tool that allows us to convert an equation from
the time domain into the **S-Domain**, where many calculations are
easier. Time-variant systems cannot be used with the Laplace Transform.

## Internal Description

If a system is linear and lumped, it can also be described using a
system of equations known as **state-space equations**. In state-space
equations, we use the variable *x* to represent the internal state of
the system. We then use *u* as the system input, and we continue to use
*y* as the system output. We can write the state-space equations as
such:

$$x'(t) = A(t)x(t) + B(t)u(t)$$

$$y(t) = C(t)x(t) + D(t)u(t)$$

We will discuss the state-space equations more when we get to the
section on **modern controls**.

## Complex Descriptions

Systems which are LTI and Lumped can also be described using a
combination of the state-space equations, and the Laplace Transform. If
we take the Laplace Transform of the state equations that we listed
above, we can get a set of functions known as the **Transfer Matrix
Functions**. We will discuss these functions in a later chapter.

## Representations

To recap, we will prepare a table with the various system properties,
and the available methods for describing the system:

:   {\| class=\"wikitable\"

\|- !Properties !! State-Space\
Equations !! Laplace\
Transform !! Transfer\
Matrix \|- \|Linear, Time-Variant, Distributed \|\| no \|\| no \|\| no
\|- \|Linear, Time-Variant, Lumped \|\| yes \|\| no \|\| no \|-
\|Linear, Time-Invariant, Distributed \|\| no \|\| yes \|\| no \|-
\|Linear, Time-Invariant, Lumped \|\| yes \|\| yes \|\| yes \|}

We will discuss all these different types of system representation later
in the book.

## Analysis

Once a system is modeled using one of the representations listed above,
the system needs to be analyzed. We can determine the system metrics and
then we can compare those metrics to our specification. If our system
meets the specifications we are finished with the design process.
However if the system does not meet the specifications (as is typically
the case), then suitable controllers and compensators need to be
designed and added to the system.

Once the controllers and compensators have been designed, the job isn\'t
finished: we need to analyze the new composite system to ensure that the
controllers work properly. Also, we need to ensure that the systems are
stable: unstable systems can be dangerous.

### Frequency Domain

For proposals, early stage designs, and quick turn around analyses a
frequency domain model is often superior to a time domain model.
Frequency domain models take disturbance PSDs (Power Spectral Densities)
directly, use transfer functions directly, and produce output or
residual PSDs directly. The answer is a steady-state response.
Oftentimes the controller is shooting for 0 so the steady-state response
is also the residual error that will be the analysis output or metric
for report.

```{=html}
<div align="center">
```
  Input   Model               Output
  ------- ------------------- --------
  PSD     Transfer Function   PSD

  : **Table 1: Frequency Domain Model Inputs and Outputs**

```{=html}
</div>
```
#### Brief Overview of the Math

Frequency domain modeling is a matter of determining the impulse
response of a system to a random process.

!Figure 1: Frequency Domain
System{width="500"}

$$S_{YY}\left(\omega\right)=G^*\left(\omega\right)G\left(\omega\right)S_{XX}= \left | G\left(\omega\right)\right \vert S_{XX}$$[^1]
where

$$S_{XX}\left(\omega\right)$$ is the one-sided input PSD in
$\frac{magnitude^2}{Hz}$

$$G\left(\omega\right)$$ is the frequency response function of the
system and

$$S_{YY}\left(\omega\right)$$ is the one-sided output PSD or auto power
spectral density function.

The frequency response function, $G\left(\omega\right)$, is related to
the impulse response function (transfer function) by

$$g\left(\tau\right)=\frac{1}{2 \pi} \int_{-\infty}^{\infty}e^{i\omega t}H\left(\omega\right)\,d\omega$$

Note some texts will state that this is only valid for random processes
which are stationary. Other texts suggest stationary and ergodic while
still others state weakly stationary processes. Some texts do not
distinguish between strictly stationary and weakly stationary. From
practice, the rule of thumb is if the PSD of the input process is the
same from hour to hour and day to day then the input PSD can be used and
the above equation is valid.

#### Notes

```{=html}
<references />
```
See a full explanation with example at
ControlTheoryPro.com

## Modeling Examples

Modeling in Control Systems is oftentimes a matter of judgement. This
judgement is developed by creating models and learning from other
people\'s models. ControlTheoryPro.com is a site with a lot of examples.
Here are links to a few of them

-   Hovering Helicopter
    Example
-   Reaction Torque Cancellation
    Example
-   List of all examples at
    ControlTheoryPro.com

## Manufacture

Once the system has been properly designed we can prototype our system
and test it. Assuming our analysis was correct and our design is good,
the prototype should work as expected. Now we can move on to manufacture
and distribute our completed systems.

[^1]: Sun, Jian-Qiao (2006). *Stochastic Dynamics and Control, Volume
    4*. Amsterdam: Elsevier Science. .


# Control Systems/Transforms

## Transforms

There are a number of transforms that we will be discussing throughout
this book, and the reader is assumed to have at least a small prior
knowledge of them. It is not the intention of this book to teach the
topic of transforms to an audience that has had no previous exposure to
them. However, we will include a brief refresher here to refamiliarize
people who maybe cannot remember the topic perfectly. If you do not know
what the **Laplace Transform** or the **Fourier Transform** are yet, it
is highly recommended that you use this page as a simple guide, and look
the information up on other sources. Specifically,
Wikipedia has lots of information on these subjects.

### Transform Basics

A **transform** is a mathematical tool that converts an equation from
one variable (or one set of variables) into a new variable (or a new set
of variables). To do this, the transform must remove all instances of
the first variable, the \"Domain Variable\", and add a new \"Range
Variable\". Integrals are excellent choices for transforms, because the
limits of the definite integral will be substituted into the domain
variable, and all instances of that variable will be removed from the
equation. An integral transform that converts from a domain variable *a*
to a range variable *b* will typically be formatted as such:

$$\mathcal{T}[f(a)] = F(b) = \int_C f(a)g(a,b)da$$

Where the function *f(a)* is the function being transformed, and
*g(a,b)* is known as the **kernel** of the transform. Typically, the
only difference between the various integral transforms is the kernel.

## Laplace Transform

The **Laplace Transform** converts an equation from the time-domain into
the so-called \"S-domain\", or the **Laplace domain**, or even the
\"Complex domain\". These are all different names for the same
mathematical space and they all may be used interchangeably in this book
and in other texts on the subject. The Transform can only be applied
under the following conditions:

1.  The system or signal in question is analog.
2.  The system or signal in question is Linear.
3.  The system or signal in question is Time-Invariant.
4.  The system or signal in question is causal.

The transform is defined as such:

$$\begin{matrix}F(s) = \mathcal{L}[f(t)] = \int_0^\infty f(t) e^{-st}dt\end{matrix}$$

Laplace transform results have been tabulated extensively. More
information on the Laplace transform, including a transform table can be
found in **the
Appendix**.

If we have a linear differential equation in the time domain:

$$\begin{matrix}y(t) = ax(t) + bx'(t) + cx''(t)\end{matrix}$$

With zero initial conditions, we can take the Laplace transform of the
equation as such:

$$\begin{matrix}Y(s) = aX(s) + bsX(s) + cs^2X(s)\end{matrix}$$

And separating, we get:

$$\begin{matrix}Y(s) = X(s)[a + bs + cs^2]\end{matrix}$$

### Inverse Laplace Transform

The **inverse Laplace Transform** is defined as such: {{-}}

$$\begin{matrix}f(t)
        = \mathcal{L}^{-1} \left\{F(s)\right\}
        = {1 \over {2\pi i}}\int_{c-i\infty}^{c+i\infty} e^{st} F(s)\,ds\end{matrix}$$

The inverse transform converts a function from the Laplace domain back
into the time domain.

### Matrices and Vectors

The Laplace Transform can be used on systems of linear equations in an
intuitive way. Let\'s say that we have a system of linear equations:

$$\begin{matrix}y_1(t) = a_1x_1(t)\end{matrix}$$

$$\begin{matrix}y_2(t) = a_2x_2(t)\end{matrix}$$

We can arrange these equations into matrix form, as shown:

$$\begin{bmatrix}y_1(t) \\ y_2(t)\end{bmatrix} = \begin{bmatrix}a_1 & 0 \\ 0 & a_2\end{bmatrix}\begin{bmatrix}x_1(t) \\x_2(t)\end{bmatrix}$$

And write this symbolically as:

$$\mathbf{y}(t) = A\mathbf{x}(t)$$

We can take the Laplace transform of both sides:

$$\mathcal{L}[\mathbf{y}(t)] = \mathbf{Y}(s) = \mathcal{L}[A\mathbf{x}(t)] = A\mathcal{L}[\mathbf{x}(t)] = A\mathbf{X}(s)$$

Which is the same as taking the transform of each individual equation in
the system of equations.

### Example: RL Circuit

Here, we are going to show a common example of a first-order system, an
**RL Circuit**. In an inductor, the relationship between the current,
*I*, and the voltage, *V*, in the time domain is expressed as a
derivative:

$$V(t) = L\frac{dI(t)}{dt}$$

Where L is a special quantity called the \"Inductance\" that is a
property of inductors.

{RI(t) + L \\frac{dI(t)}{dt}}V\_{in}(t)`</math>`{=html}

This is a very complicated equation, and will be difficult to solve
unless we employ the Laplace transform:

$$V_{out}(s) = \frac{Ls}{R + Ls}V_{in}(s)$$

We can divide top and bottom by L, and move V~in~ to the other side:

$$\frac{V_{out}}{V_{in}} = \frac{s}{\frac{R}{L} + s}$$

And using a simple table look-up, we can solve this for the time-domain
relationship between the circuit input and the circuit output:

$$\frac{V_{out}}{V_{in}} = \frac{d}{dt}e^{\left(\frac{-Rt}{L}\right)}u(t)$$}}

### Partial Fraction Expansion

Laplace transform pairs are extensively tabulated, but frequently we
have transfer functions and other equations that do not have a tabulated
inverse transform. If our equation is a fraction, we can often utilize
**Partial Fraction Expansion** (PFE) to create a set of simpler terms
that will have readily available inverse transforms. This section is
going to give a brief reminder about PFE, for those who have already
learned the topic. This refresher will be in the form of several
examples of the process, as it relates to the Laplace Transform. People
who are unfamiliar with PFE are encouraged to read more about it in
**Calculus**.

### Example: Second-Order System

### Example: Fourth-Order System

\\to \\frac{t\^{n}}{n!}e\^{-\\alpha t} \\cdot u(t) `</math>`{=html}

We can plug in our values for *A*, *B*, *C*, and *D* into our expansion,
and try to convert it into the form above.

$$F(s)=\frac{A}{s}+\frac{B}{(s+10)^3}+\frac{C}{(s+10)^2}+\frac{D}{s+10}$$

$$F(s)=A\frac{1}{s}+B\frac{1}{(s+10)^3}+C\frac{1}{(s+10)^2}+D\frac{1}{s+10}$$

$$F(s)=1\frac{1}{s}+26\frac{1}{(s+10)^3}+69\frac{1}{(s+10)^2}-1\frac{1}{s+10}$$

$$f(t)=u(t)+13t^2e^{-10t}+69te^{-10t}-e^{-10t}$$}}

### Example: Complex Roots

### Example: Sixth-Order System

### Final Value Theorem

The **Final Value Theorem** allows us to determine the value of the time
domain equation, as the time approaches infinity, from the S domain
equation. In Control Engineering, the Final Value Theorem is used most
frequently to determine the steady-state value of a system. The real
part of the poles of the function must be \<0.

$$\lim_{t \to \infty}x(t) = \lim_{s \to 0} s X(s)$$

From our chapter on system metrics, you may recognize the value of the
system at time infinity as the steady-state time of the system. The
difference between the steady state value and the expected output value
we remember as being the steady-state error of the system. Using the
Final Value Theorem, we can find the steady-state value and the
steady-state error of the system in the Complex S domain.

### Example: Final Value Theorem

### Initial Value Theorem

Akin to the final value theorem, the **Initial Value Theorem** allows us
to determine the initial value of the system (the value at time zero)
from the S-Domain Equation. The initial value theorem is used most
frequently to determine the starting conditions, or the \"initial
conditions\" of a system.

$$x(0) = \lim_{s \to \infty} s X(s)$$

### Common Transforms

We will now show you the transforms of the three functions we have
already learned about: The unit step, the unit ramp, and the unit
parabola. The transform of the unit step function is given by:

$$\mathcal{L}[u(t)] = \frac{1}{s}$$

And since the unit ramp is the integral of the unit step, we can
multiply the above result times *1/s* to get the transform of the unit
ramp:

$$\mathcal{L}[r(t)] = \frac{1}{s^2}$$

Again, we can multiply by *1/s* to get the transform of the unit
parabola:

$$\mathcal{L}[p(t)] = \frac{1}{s^3}$$

## Fourier Transform

The **Fourier Transform** is very similar to the Laplace transform. The
fourier transform uses the assumption that any finite time-domain signal
can be broken into an infinite sum of sinusoidal (sine and cosine waves)
signals. Under this assumption, the Fourier Transform converts a
time-domain signal into its frequency-domain representation, as a
function of the radial frequency, ω, The Fourier Transform is defined as
such:

$$F(j\omega) = \mathcal{F}[f(t)] = \int_0^\infty f(t) e^{-j\omega t} dt$$

We can now show that the Fourier Transform is equivalent to the Laplace
transform, when the following condition is true:

$$\begin{matrix}s = j\omega\end{matrix}$$

Because the Laplace and Fourier Transforms are so closely related, it
does not make much sense to use both transforms for all problems. This
book, therefore, will concentrate on the Laplace transform for nearly
all subjects, except those problems that deal directly with frequency
values. For frequency problems, it makes life much easier to use the
Fourier Transform representation.

Like the Laplace Transform, the Fourier Transform has been extensively
tabulated. Properties of the Fourier transform, in addition to a table
of common transforms is available in **the
Appendix**.

### Inverse Fourier Transform

The **inverse Fourier Transform** is defined as follows: {{-}}

$$f(t)
        = \mathcal{F}^{-1}\left\{F(j\omega)\right\}
        = \frac{1}{2\pi}\int_{-\infty}^\infty F(j\omega) e^{j\omega t} d\omega$$

This transform is nearly identical to the Fourier Transform.

## Complex Plane

![](S_Plane.svg "S_Plane.svg"){width="200"}

Using the above equivalence, we can show that the Laplace transform is
always equal to the Fourier Transform, if the variable *s* is an
imaginary number. However, the Laplace transform is different if *s* is
a real or a complex variable. As such, we generally define *s* to have
both a real part and an imaginary part, as such:

$$\begin{matrix}s = \sigma + j\omega\end{matrix}$$

And we can show that *s = j*ω if σ*= 0*.

Since the variable *s* can be broken down into 2 independent values, it
is frequently of some value to graph the variable *s* on its own special
\"S-plane\". The S-plane graphs the variable σ on the horizontal axis,
and the value of *j*ω on the vertical axis. This axis arrangement is
shown at right.

{{-}}

## Euler\'s Formula

There is an important result from calculus that is known as **Euler\'s
Formula**, or \"Euler\'s Relation\". This important formula relates the
important values of *e*, *j*, π, 1 and 0:

$$\begin{matrix}e^{j\pi} + 1 = 0\end{matrix}$$

However, this result is derived from the following equation, setting ω
to π:

$$\begin{matrix}e^{j\omega} = \cos(\omega) + j\sin(\omega)\end{matrix}$$

This formula will be used extensively in some of the chapters of this
book, so it is important to become familiar with it now.

## MATLAB

The MATLAB symbolic toolbox contains functions to compute the Laplace
and Fourier transforms automatically. The function **laplace**, and the
function **fourier** can be used to calculate the Laplace and Fourier
transforms of the input functions, respectively. For instance, the code:

`t = sym('t');`\
`fx = 30*t^2 + 20*t;`\
`laplace(fx)`

produces the output:

`ans =`\
\
`60/s^3+20/s^2`

We will discuss these functions more in The
Appendix.

## Further reading

-   Digital Signal Processing/Continuous-Time Fourier
    Transform
-   Signals and Systems/Aperiodic
    Signals
-   Circuit Theory/Laplace
    Transform


# Control Systems/Transfer Functions

## Transfer Functions

A **Transfer Function** is the ratio of the output of a system to the
input of a system, in the Laplace domain considering its initial
conditions and equilibrium point to be zero. This assumption is relaxed
for systems observing transience. If we have an input function of
*X(s)*, and an output function *Y(s)*, we define the transfer function
*H(s)* to be:

$$H(s) = {Y(s) \over X(s)}$$

Readers who have read the Circuit Theory
book will recognize the transfer function as being the impedance,
admittance, impedance ratio of a voltage divider or the admittance ratio
of a current divider.

![](Laplace_Block.svg "Laplace_Block.svg"){width="400"}

## Impulse Response

For comparison, we will consider the time-domain equivalent to the above
input/output relationship. In the time domain, we generally denote the
input to a system as *x(t)*, and the output of the system as *y(t)*. The
relationship between the input and the output is denoted as the
**impulse response**, *h(t)*.

We define the impulse response as being the relationship between the
system output to its input. We can use the following equation to define
the impulse response:

$$h(t) = \frac{y(t)}{x(t)}$$

### Impulse Function

It would be handy at this point to define precisely what an \"impulse\"
is. The **Impulse Function**, denoted with δ*(t)* is a special function
defined piece-wise as follows:

$$\delta(t) = \left\{
\begin{matrix}
  0, & t < 0
\\
  \mbox{undefined}, & t = 0
\\
  0, & t > 0
\end{matrix}\right.$$

The impulse function is also known as the **delta function** because
it\'s denoted with the Greek lower-case letter δ. The delta function is
typically graphed as an arrow towards infinity, as shown below:

![](Delta_Function.svg "Delta_Function.svg")

It is drawn as an arrow because it is difficult to show a single point
at infinity in any other graphing method. Notice how the arrow only
exists at location 0, and does not exist for any other time *t*. The
delta function works with regular time shifts just like any other
function. For instance, we can graph the function δ*(t - N)* by shifting
the function δ*(t)* to the right, as such:

![](DeltaN_Function.svg "DeltaN_Function.svg")

An examination of the impulse function will show that it is related to
the unit-step function as follows:

$$\delta(t) = \frac{du(t)}{dt}$$

and

$$u(t) = \int \delta(t) dt$$

The impulse function is not defined at point *t = 0*, but the impulse
must always satisfy the following condition, or else it is not a true
impulse function:

$$\int_{-\infty}^\infty \delta(t)dt = 1$$

The response of a system to an impulse input is called the **impulse
response**. Now, to get the Laplace Transform of the impulse function,
we take the derivative of the unit step function, which means we
multiply the transform of the unit step function by s:

$$\mathcal{L}[u(t)] = U(s) = \frac{1}{s}$$

$$\mathcal{L}[\delta(t)] = sU(s) = \frac{s}{s} = 1$$

This result can be verified in the transform tables in **The
Appendix**.

### Step Response

Similar to the impulse response, the **step response** of a system is
the output of the system when a unit step function is used as the input.
The step response is a common analysis tool used to determine certain
metrics about a system. Typically, when a new system is designed, the
step response of the system is the first characteristic of the system to
be analyzed.

## Convolution

However, the impulse response cannot be used to find the system output
from the system input in the same manner as the transfer function. If we
have the system input and the impulse response of the system, we can
calculate the system output using the **convolution operation** as such:

$$y(t) = h(t) * x(t)$$

Where \" \* \" (asterisk) denotes the convolution operation. Convolution
is a complicated combination of multiplication, integration and
time-shifting. We can define the convolution between two functions,
*a(t)* and *b(t)* as the following:

$$(a*b)(t) = (b*a)(t) = \int_{-\infty}^\infty a(\tau)b(t - \tau)d\tau$$

(The variable τ (Greek tau) is a dummy variable for integration). This
operation can be difficult to perform. Therefore, many people prefer to
use the Laplace Transform (or another transform) to convert the
convolution operation into a multiplication operation, through the
**Convolution Theorem**.

### Time-Invariant System Response

If the system in question is time-invariant, then the general
description of the system can be replaced by a convolution integral of
the system\'s impulse response and the system input. We can call this
the **convolution description** of a system, and define it below:

$$y(t) = x(t) * h(t) = \int_{-\infty}^\infty x(\tau)h(t - \tau)d\tau$$

## Convolution Theorem

This method of solving for the output of a system is quite tedious, and
in fact it can waste a large amount of time if you want to solve a
system for a variety of input signals. Luckily, the Laplace transform
has a special property, called the **Convolution Theorem**, that makes
the operation of convolution easier:

The Convolution Theorem can be expressed using the following equations:

$$\mathcal{L}[f(t) * g(t)] = F(s)G(s)$$

$$\mathcal{L}[f(t)g(t)] = F(s) * G(s)$$

This also serves as a good example of the property of **Duality**.

## Using the Transfer Function

The Transfer Function fully describes a control system. The Order, Type
and Frequency response can all be taken from this specific function.
Nyquist and Bode plots can be drawn from the open loop Transfer
Function. These plots show the stability of the system when the loop is
closed. Using the denominator of the transfer function, called the
characteristic equation, roots of the system can be derived.

For all these reasons and more, the Transfer function is an important
aspect of classical control systems. Let\'s start out with the
definition:

If the complex Laplace variable is *s*, then we generally denote the
transfer function of a system as either *G(s)* or *H(s)*. If the system
input is *X(s)*, and the system output is *Y(s)*, then the transfer
function can be defined as such:

$$H(s) = \frac{Y(s)}{X(s)}$$

If we know the input to a given system, and we have the transfer
function of the system, we can solve for the system output by
multiplying:

$$Y(s) = H(s)X(s)$$

### Example: Impulse Response

### Example: Step Response

### Example: MATLAB Step Response

## Frequency Response

The **Frequency Response** is similar to the Transfer function, except
that it is the relationship between the system output and input in the
complex Fourier Domain, not the Laplace domain. We can obtain the
frequency response from the transfer function, by using the following
change of variables:

$$s = j\omega$$

![](Fourier_Block.svg "Fourier_Block.svg"){width="400"}

Because the frequency response and the transfer function are so closely
related, typically only one is ever calculated, and the other is gained
by simple variable substitution. However, despite the close relationship
between the two representations, they are both useful individually, and
are each used for different purposes.


# Control Systems/Poles and Zeros

## Poles and Zeros

**Poles** and **Zeros** of a transfer function are the frequencies for
which the value of the denominator and numerator of transfer function
becomes infinite and zero respectively. The values of the poles and the
zeros of a system determine whether the system is stable, and how well
the system performs. Control systems, in the most simple sense, can be
designed simply by assigning specific values to the poles and zeros of
the system.

Physically realizable control systems must have a number of poles
greater than the number of zeros. Systems that satisfy this relationship
are called **Proper**. We will elaborate on this below.

## Time-Domain Relationships

Let\'s say that we have a transfer function with 3 poles:

$$H(s) = \frac{a}{(s - l)(s - m)(s - n)}$$

The poles are located at s = **l**, **m**, **n**. Now, we can use
partial fraction expansion to separate out the transfer function:

$$H(s) = \frac{a}{(s - l)(s - m)(s - n)} = \frac{A}{s-l} + \frac{B}{s-m} + \frac{C}{s-n}$$

Using the inverse transform on each of these component fractions
(looking up the transforms in our table), we get the following:

$$h(t) = Ae^{lt}u(t) + Be^{mt}u(t) + Ce^{nt}u(t)$$

But, since s is a complex variable, **l** **m** and **n** can all
potentially be complex numbers, with a real part (σ) and an imaginary
part (jω). If we just look at the first term:

$$Ae^{lt}u(t) = Ae^{(\sigma_l + j\omega_l)t}u(t) = Ae^{\sigma_l t}e^{j\omega_l t}u(t)$$

Using **Euler\'s Equation** on the
imaginary exponent, we get:

$$Ae^{\sigma_l t}[\cos(\omega_l t) + j\sin(\omega_l t)]u(t)$$

If a complex pole is present it is always accompanied by another pole
that is its complex conjugate. The imaginary parts of their time domain
representations thus cancel and we are left with 2 of the same real
parts. Assuming that the complex conjugate pole of the first term is
present, we can take 2 times the real part of this equation and we are
left with our final result:

$$2Ae^{\sigma_l t}\cos(\omega_l t)u(t)$$

We can see from this equation that every pole will have an exponential
part, and a sinusoidal part to its response. We can also go about
constructing some rules:

1.  if σ~l~ = 0, the response of the pole is a perfect sinusoidal (an
    oscillator)
2.  if ω~l~ = 0, the response of the pole is a perfect exponential.
3.  if σ~l~ \< 0, the exponential part of the response will decay
    towards zero.
4.  if σ~l~ \> 0, the exponential part of the response will rise towards
    infinity.

From the last two rules, we can see that all poles of the system must
have negative real parts, and therefore they must all have the form (s +
l) for the system to be stable. We will discuss stability in later
chapters.

## What are Poles and Zeros

Let\'s say we have a transfer function defined as a ratio of two
polynomials:

$$H(s) = {N(s) \over D(s)}$$

Where *N(s)* and *D(s)* are simple polynomials. **Zeros** are the roots
of *N(s)* (the numerator of the transfer function) obtained by setting
*N(s) = 0* and solving for *s*.

**Poles** are the roots of *D(s)* (the denominator of the transfer
function), obtained by setting *D(s) = 0* and solving for *s*. Because
of our restriction above, that a transfer function must not have more
zeros than poles, we can state that the polynomial order of *D(s)* must
be greater than or equal to the polynomial order of *N(s)*.

{{-}}

### Example

## Effects of Poles and Zeros

As *s* approaches a zero, the numerator of the transfer function (and
therefore the transfer function itself) approaches the value 0. When *s*
approaches a pole, the denominator of the transfer function approaches
zero, and the value of the transfer function approaches infinity. An
output value of infinity should raise an alarm bell for people who are
familiar with BIBO stability. We will discuss this later.

As we have seen above, the locations of the poles, and the values of the
real and imaginary parts of the pole determine the response of the
system. Real parts correspond to exponentials, and imaginary parts
correspond to sinusoidal values. Addition of poles to the transfer
function has the effect of pulling the root locus to the right, making
the system less stable. Addition of zeros to the transfer function has
the effect of pulling the root locus to the left, making the system more
stable.

## Second-Order Systems

The canonical form for a second order system is as follows:

$$H(s) = \frac{K\omega^2}{s^2 + 2\zeta\omega s + \omega^2}$$

Where K is the **system gain**, ζ is called the **damping ratio** of the
function, and ω is called the **natural frequency** of the system. ζ and
ω, if exactly known for a second order system, the time responses can be
easily plotted and stability can easily be checked. More information on
second order systems can be found
here.

### Damping Ratio

The **damping ratio** of a second-order system, denoted with the Greek
letter zeta (ζ), is a real number that defines the damping properties of
the system. More damping has the effect of less percent overshoot, and
slower settling time. Damping is the inherent ability of the system to
oppose the oscillatory nature of the system\'s transient response.
Larger values of damping coefficient or damping factor produces
transient responses with lesser oscillatory nature.

### Natural Frequency

The natural frequency is occasionally written with a subscript:

$$\omega \to \omega_n$$

We will omit the subscript when it is clear that we are talking about
the natural frequency, but we will include the subscript when we are
using other values for the variable ω. Also, $\omega~=~\omega_n$ when
$\zeta~=0$.

## Higher-Order Systems


# Control Systems/State-Space Equations

## Time-Domain Approach

The \"Classical\" method of controls (what we have been studying so far)
has been based mostly in the transform domain. When we want to control
the system in general, we represent it using the Laplace transform
(Z-Transform for digital systems) and when we want to examine the
frequency characteristics of a system we use the Fourier Transform. The
question arises, why do we do this?

Let\'s look at a basic second-order Laplace Transform transfer function:

$$\frac{Y(s)}{X(s)} = G(s) = \frac{1 + s}{1 + 2s + 5s^2}$$

We can decompose this equation in terms of the system inputs and
outputs:

$$(1 + 2s + 5 s^2)Y(s) = (1 + s)X(s)$$

Now, when we take the inverse Laplace transform of our equation, we can
see that:

$$y(t) + 2\frac{d y(t)}{dt} + 5\frac{d^2y(t)}{dt^2} = x(t) + \frac{dx(t)}{dt}$$

The Laplace transform is transforming the fact that we are dealing with
second-order differential equations. The Laplace transform moves a
system out of the time-domain into the complex frequency domain so we
can study and manipulate our systems as algebraic polynomials instead of
linear ODEs. Given the complexity of differential equations, why would
we ever want to work in the time domain?

It turns out that to decompose our higher-order differential equations
into multiple first-order equations, one can find a new method for
easily manipulating the system *without having to use integral
transforms*. The solution to this problem is **state variables**. By
taking our multiple first-order differential equations and analyzing
them in vector form, we can not only do the same things we were doing in
the time domain using simple matrix algebra, but now we can easily
account for systems with multiple inputs and outputs without adding much
unnecessary complexity. This demonstrates why the \"modern\" state-space
approach to controls has become popular.

## State-Space

In a state-space system, the internal state of the system is explicitly
accounted for by an equation known as the **state equation**. The system
output is given in terms of a combination of the current system state,
and the current system input, through the **output equation**. These two
equations form a system of equations known collectively as **state-space
equations**. The state-space is the vector space that consists of all
the possible internal states of the system.

For a system to be modeled using the state-space method, the system must
meet this requirement:

1.  **The system must be \"lumped\"**

\"Lumped\" in this context, means that we can find a
*finite*-dimensional state-space vector which fully characterises all
such internal states of the system.

This text mostly considers linear state-space systems where the state
and output equations satisfy the superposition principle. However, the
state-space approach is equally valid for nonlinear systems although
some specific methods are not applicable to nonlinear systems.

#### State

Central to the state-space notation is the idea of a **state**. A state
of a system is the current value of internal elements of the system
which change separately (but are not completely unrelated) to the output
of the system. In essence, the state of a system is an explicit account
of the values of the internal system components. Here are some examples:

## State Variables

When modeling a system using a state-space equation, we first need to
define three vectors:

Input variables: A SISO (Single-Input Single-Output) system will only have one input value, but a MIMO (Multiple-Input Multiple-Output) system may have multiple inputs. We need to define all the inputs to the system and arrange them into a vector.\
Output variables: This is the system output value, and in the case of MIMO systems we may have several. Output variables should be independent of one another, and only dependent on a linear combination of the input vector and the state vector.\
State Variables: The state variables represent values from inside the system that can change over time. In an electric circuit for instance, the node voltages or the mesh currents can be state variables. In a mechanical system, the forces applied by springs, gravity, and dashpots can be state variables.

We denote the input variables with *u*, the output variables with *y*,
and the state variables with *x*. In essence, we have the following
relationship:

$$y = f(x, u)$$

Where *f(x, u)* is our system. Also, the state variables can change with
respect to the current state and the system input:

$$x' = g(x, u)$$

Where *x\'* is the rate of change of the state variables. We will define
*f(u, x)* and *g(u, x)* in the next chapter.

## Multi-Input, Multi-Output

In the Laplace domain, if we want to account for systems with multiple
inputs and multiple outputs, we are going to need to rely on the
principle of superposition to create a system of simultaneous Laplace
equations for each input and output. For such systems, the classical
approach not only doesn\'t simplify the situation, but because the
systems of equations need to be transformed into the frequency domain
first, manipulated, and then transformed back into the time domain, they
can actually be more difficult to work with. However, the Laplace domain
technique can be combined with the State-Space techniques discussed in
the next few chapters to bring out the best features of both techniques.
We will discuss MIMO systems in the MIMO Systems
Chapter.

## State-Space Equations

In a state-space system representation, we have a system of two
equations: an equation for determining the state of the system, and
another equation for determining the output of the system. We will use
the variable *y(t)* as the output of the system, *x(t)* as the state of
the system, and *u(t)* as the input of the system. We use the notation
*x\'(t)* (note the prime) for the first derivative of the state vector
of the system, as dependent on the current state of the system and the
current input. Symbolically, we say that there are transforms **g** and
**h**, that display this relationship:

$$x'(t) = g[t_0, t, x(t), x(0), u(t)]$$

$$y(t) = h[t, x(t), u(t)]$$

The first equation shows that the system state change is dependent on
the previous system state, the initial state of the system, the time,
and the system inputs. The second equation shows that the system output
is dependent on the current system state, the system input, and the
current time.

If the system state change *x\'(t)* and the system output *y(t)* are
linear combinations of the system state and input vectors, then we can
say the systems are linear systems, and we can rewrite them in matrix
form:

$$x'(t) = A(t)x(t) + B(t)u(t)$$

$$y(t) = C(t)x(t) + D(t)u(t)$$

If the systems themselves are time-invariant, we can re-write this as
follows:

$$x'(t) = Ax(t) + Bu(t)$$

$$y(t) = Cx(t) + Du(t)$$

The **State Equation** shows the relationship between the system\'s
current state and its input, and the future state of the system. The
**Output Equation** shows the relationship between the system state and
its input, and the output. These equations show that in a given system,
the current output is dependent on the current input and the current
state. The future state is also dependent on the current state and the
current input.

It is important to note at this point that the state space equations of
a particular system are not unique, and there are an infinite number of
ways to represent these equations by manipulating the *A*, *B*, *C* and
*D* matrices using row operations. There are a number of \"standard
forms\" for these matrices, however, that make certain computations
easier. Converting between these forms will require knowledge of linear
algebra.

### Matrices: A B C D

Our system has the form:

$$\mathbf{x}'(t) = \mathbf{g}[t_0, t, \mathbf{x}(t), x(0), \mathbf{u}(t)]$$

$$\mathbf{y}(t) = \mathbf{h}[t, \mathbf{x}(t), \mathbf{u}(t)]$$

We\'ve bolded several quantities to try and reinforce the fact that they
can be vectors, not just scalar quantities. If these systems are
time-invariant, we can simplify them by removing the time variables:

$$\mathbf{x}'(t) = \mathbf{g}[\mathbf{x}(t), x(0), \mathbf{u}(t)]$$

$$\mathbf{y}(t) = \mathbf{h}[\mathbf{x}(t), \mathbf{u}(t)]$$

Now, if we take the partial derivatives of these functions with respect
to the input and the state vector at time *t~0~*, we get our system
matrices:

$$A = \mathbf{g}_x[x(0), x(0), u(0)]$$

$$B = \mathbf{g}_u[x(0), x(0), u(0)]$$

$$C = \mathbf{h}_x[x(0), u(0)]$$

$$D = \mathbf{h}_u[x(0), u(0)]$$

In our time-invariant state space equations, we write these matrices and
their relationships as:

$$x'(t) = Ax(t) + Bu(t)$$

$$y(t)  = Cx(t) + Du(t)$$

We have four constant matrices: *A*, *B*, *C*, and *D*. We will explain
these matrices below:

Matrix A:Matrix *A* is the **system matrix**, and relates how the current state affects the state change *x\'*. If the state change is not dependent on the current state, *A* will be the zero matrix. The exponential of the state matrix, *e^At^* is called the **state transition matrix**, and is an important function that we will describe below.\
Matrix B:Matrix *B* is the **control matrix**, and determines how the system input affects the state change. If the state change is not dependent on the system input, then *B* will be the zero matrix.\
Matrix C:Matrix *C* is the **output matrix**, and determines the relationship between the system state and the system output.\
Matrix D:Matrix *D* is the **feed-forward matrix**, and allows for the system input to affect the system output directly. A basic feedback system like those we have previously considered do not have a feed-forward element, and therefore for most of the systems we have already considered, the *D* matrix is the zero matrix.

### Matrix Dimensions

Because we are adding and multiplying multiple matrices and vectors
together, we need to be absolutely certain that the matrices have
compatible dimensions, or else the equations will be undefined. For
integer values *p*, *q*, and *r*, the dimensions of the system matrices
and vectors are defined as follows:

:   {\| class=\"wikitable\"

!Vectors \|\| Matrices \|- \|

-   $x: p \times 1$
-   $x': p\times 1$
-   $u: q \times 1$
-   $y: r \times 1$

\|

-   $A: p \times p$
-   $B: p \times q$
-   $C: r \times p$
-   $D: r \times q$

\|}

If the matrix and vector dimensions do not agree with one another, the
equations are invalid and the results will be meaningless. Matrices and
vectors must have compatible dimensions or they cannot be combined using
matrix operations.

For the rest of the book, we will be using the small template on the
right as a reminder about the matrix dimensions, so that we can keep a
constant notation throughout the book.

### Notational Shorthand

The state equations and the output equations of systems can be expressed
in terms of matrices *A*, *B*, *C*, and *D*. Because the form of these
equations is always the same, we can use an ordered quadruplet to denote
a system. We can use the shorthand *(A, B, C, D)* to denote a complete
state-space representation. Also, because the state equation is very
important for our later analysis, we can write an ordered pair *(A, B)*
to refer to the state equation:

$$(A, B) \to x' = Ax + Bu$$

$$(A, B, C, D) \to \left\{\begin{matrix}x' = Ax + Bu \\ y = Cx + Du \end{matrix}\right.$$

## Obtaining the State-Space Equations

The beauty of state equations, is that they can be used to transparently
describe systems that are both continuous and discrete in nature. Some
texts will differentiate notation between discrete and continuous cases,
but this text will not make such a distinction. Instead we will opt to
use the generic coefficient matrices *A*, *B*, *C* and *D* for both
continuous and discrete systems. Occasionally this book may employ the
subscript *C* to denote a continuous-time version of the matrix, and the
subscript *D* to denote the discrete-time version of the same matrix.
Other texts may use the letters *F*, *H*, and *G* for continuous systems
and *Γ*, and *Θ* for use in discrete systems. However, if we keep track
of our time-domain system, we don\'t need to worry about such notations.

### From Differential Equations

### From Transfer Functions

The method of obtaining the state-space equations from the Laplace
domain transfer functions are very similar to the method of obtaining
them from the time-domain differential equations. We call the process of
converting a system description from the Laplace domain to the
state-space domain **realization**. We will discuss realization in more
detail in a later chapter. In general, let\'s say that we have a
transfer function of the form:

$$T(s) = \frac{s^m+a_{m-1}s^{m-1} +\cdots+a_0}{s^n+b_{n-1}s^{n-1}+\cdots+b_0}$$

We can write our *A*, *B*, *C*, and *D* matrices as follows:

:   {\|class=\"wikitable\"

\|- \|$A = \begin{bmatrix}0 & 1 & 0 & \cdots & 0 \\
                          0 & 0 & 1 & \cdots & 0 \\
                          \vdots &\vdots &\vdots & \ddots & \vdots \\
                          0 & 0 & 0 & \cdots & 1 \\
                          -b_0 & -b_1 & -b_2 & \cdots & -b_{n-1}
           \end{bmatrix}$ \|-
\|$B = \begin{bmatrix}0 \\ 0 \\ \vdots \\1\end{bmatrix}$ \|-
\|$C = \begin{bmatrix}a_0 & a_1 & \cdots & a_{m-1}\end{bmatrix}$ \|-
\|$D = 0$ \|}

This form of the equations is known as the **controllable canonical
form** of the system matrices, and we will discuss this later.

Notice that to perform this method, the denominator and numerator
polynomials must be *monic*, the coefficients of the highest-order term
must be 1. If the coefficient of the highest order term is not 1, you
must divide your equation by that coefficient to make it 1.

## State-Space Representation

As an important note, remember that the state variables *x* are
user-defined and therefore are arbitrary. There are any number of ways
to define *x* for a particular problem, each of which are going to lead
to different state space equations.

Consider the previous continuous-time example. We can rewrite the
equation in the form

$$\frac{d}{dt}\left[\frac{d^2y(t)}{dt^2} + a_2\frac{dy(t)}{dt} + a_1y(t)\right] + a_0y(t)=u(t)$$.

We now define the state variables

$$x_1 = y(t)$$

$$x_2 = \frac{dy(t)}{dt}$$

$$x_3 = \frac{d^2y(t)}{dt^2} + a_2\frac{dy(t)}{dt} + a_1y(t)$$

with first-order derivatives

$$x_1' = \frac{dy(t)}{dt} = x_2$$

$$x_2' = \frac{d^2y(t)}{dt^2} = - a_1x_1 - a_2x_2 + x_3$$ (suspected
error here. Fails to account that $$\frac{d}{dt}\left[\right]$$.
encapsulates $$\frac{d^2y(t)}{dt^2} + a_2\frac{dy(t)}{dt} + a_1y(t)$$
five lines earlier.)

$$x_3' = -a_0y(t) + u(t)$$

The state-space equations for the system will then be given by

$$x' = \begin{bmatrix}
               0 & 1 & 0 \\
               -a_1 & -a_2 & 1 \\
               -a_0 & 0 & 0
             \end{bmatrix} x(t) +
             \begin{bmatrix}
               0 \\ 0 \\ 1
             \end{bmatrix} u(t)$$

$$y(t) = \begin{bmatrix}
                 1 & 0 & 0
               \end{bmatrix} x(t)$$

*x* may also be used in any number of variable transformations, as a
matter of mathematical convenience. However, the variables *y* and *u*
correspond to physical signals, and may not be arbitrarily selected,
redefined, or transformed as *x* can be.

### Example: Dummy Variables

## Discretization

If we have a system *(A, B, C, D)* that is defined in continuous time,
we can **discretize** the system so that an equivalent process can be
performed using a digital computer. We can use the definition of the
derivative, as such:

$$x'(t) = \lim_{T\to 0} \frac{x(t + T) - x(t)}{T}$$

And substituting this into the state equation with some approximation
(and ignoring the limit for now) gives us:

$$\lim_{T\to 0} \frac{x(t + T) - x(t)}{T} = Ax(t) + Bu(t)$$

$$x(t + T) = x(t) + Ax(t)T + Bu(t)T$$

$$x(t + T) = (1 + AT)x(t) + (BT)u(t)$$

We are able to remove that limit because in a discrete system, the time
interval between samples is positive and non-negligible. By definition,
a discrete system is only defined at certain time points, and not at all
time points as the limit would have indicated. In a discrete system, we
are interested only in the value of the system at discrete points. If
those points are evenly spaced by every *T* seconds (the sampling time),
then the samples of the system occur at *t = kT*, where *k* is an
integer. Substituting *kT* for *t* into our equation above gives us:

$$x(kT + T) = (1 + AT)x(kT) + TBu(kT)$$

Or, using the square-bracket shorthand that we\'ve developed earlier, we
can write:

$$x[k+1] = (1 + AT)x[k] + TBu[k]$$

In this form, the state-space system can be implemented quite easily
into a digital computer system using software, not complicated analog
hardware. We will discuss this relationship and digital systems more
specifically in a later chapter.

We will write out the discrete-time state-space equations as:

$$x[n+1] = A_dx[n] + B_du[n]$$

$$y[n] = C_dx[n] + D_du[n]$$

## Note on Notations

The variable *T* is a common variable in control systems, especially
when talking about the beginning and end points of a continuous-time
system, or when discussing the sampling time of a digital system.
However, another common use of the letter *T* is to signify the
transpose operation on a matrix. To alleviate this ambiguity, we will
denote the transpose of a matrix with a *prime*:

$$A^T \to A'$$

Where *A\'* is the transpose of matrix *A*.

The prime notation is also frequently used to denote the
time-derivative. Most of the matrices that we will be talking about are
time-invariant; there is no ambiguity because we will never take the
time derivative of a time-invariant matrix. However, for a time-variant
matrix we will use the following notations to distinguish between the
time-derivative and the transpose:

$$A(t)'$$ the transpose.

$$A'(t)$$ the time-derivative.

Note that certain variables which are time-variant are not written with
the *(t)* postscript, such as the variables *x*, *y*, and *u*. For these
variables, the default behavior of the prime is the time-derivative,
such as in the state equation. If the transpose needs to be taken of one
of these vectors, the *(t)\'* postfix will be added explicitly to
correspond to our notation above.

For instances where we need to use the Hermitian transpose, we will use
the notation:

$$A^H$$

This notation is common in other literature, and raises no obvious
ambiguities here.

## MATLAB Representation

State-space systems can be represented in MATLAB using the 4 system
matrices, A, B, C, and D. We can create a system data structure using
the **ss** function:

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

Systems created in this way can be manipulated in the same way that the
transfer function descriptions (described earlier) can be manipulated.
To convert a transfer function to a state-space representation, we can
use the **tf2ss** function:

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

And to perform the opposite operation, we can use the **ss2tf**
function:

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

he:תורת הבקרה/משתני מצב


# Control Systems/Linear System Solutions

## State Equation Solutions

The state equation is a first-order linear differential equation, or
(more precisely) a system of linear differential equations. Because this
is a first-order equation, we can use results from Ordinary
Differential Equations to
find a general solution to the equation in terms of the state-variable
*x*. Once the state equation has been solved for *x*, that solution can
be plugged into the output equation. The resulting equation will show
the direct relationship between the system input and the system output,
without the need to account explicitly for the internal state of the
system. The sections in this chapter will discuss the solutions to the
state-space equations, starting with the easiest case (Time-invariant,
no input), and ending with the most difficult case (Time-variant
systems).

## Solving for x(t) With Zero Input

Looking again at the state equation:

$$x' = Ax(t) + Bu(t)$$

We can see that this equation is a first-order differential equation,
except that the variables are vectors, and the coefficients are
matrices. However, because of the rules of matrix calculus, these
distinctions don\'t matter. We can ignore the input term (for now), and
rewrite this equation in the following form:

$$\frac{dx(t)}{dt} = Ax(t)$$

And we can separate out the variables as such:

$$\frac{dx(t)}{x(t)} = A dt$$

Integrating both sides, and raising both sides to a power of *e*, we
obtain the result:

$$x(t) = e^{At+C}$$

Where *C* is a constant. We can assign *D = e^C^* to make the equation
easier, but we also know that *D* will then be the initial conditions of
the system. This becomes obvious if we plug the value zero into the
variable *t*. The final solution to this equation then is given as:

$$x(t) = e^{A(t-t_0)}x(t_0)$$

We call the matrix exponential *e^At^* the **state-transition matrix**,
and calculating it, while difficult at times, is crucial to analyzing
and manipulating systems. We will talk more about calculating the matrix
exponential below.

## Solving for x(t) With Non-Zero Input

If, however, our input is non-zero (as is generally the case with any
interesting system), our solution is a little bit more complicated.
Notice that now that we have our input term in the equation, we will no
longer be able to separate the variables and integrate both sides
easily.

$$x'(t) = Ax(t) + Bu(t)$$

We subtract to get the $Ax(t)$ on the left side, and then we do
something curious; we premultiply both sides by the inverse state
transition matrix:

$$e^{-At}x'(t) - e^{-At}Ax(t) = e^{-At}Bu(t)$$

The rationale for this last step may seem fuzzy at best, so we will
illustrate the point with an example:

### Example

Using the result from our example, we can condense the left side of our
equation into a derivative:

$$\frac{d(e^{-At}x(t))}{dt} = e^{-At}Bu(t)$$

Now we can integrate both sides, from the initial time (*t~0~*) to the
current time (*t*), using a dummy variable τ, we will get closer to our
result. Finally, if we premultiply by e^At^, we get our final result:

$$x(t) = e^{A(t-t_0)}x(t_0) + \int_{t_0}^{t}e^{A(t - \tau)}Bu(\tau)d\tau$$

If we plug this solution into the output equation, we get:

$$y(t) = Ce^{A(t-t_0)}x(t_0) + C\int_{t_0}^{t}e^{A(t - \tau)}Bu(\tau)d\tau + Du(t)$$

This is the general Time-Invariant solution to the state space
equations, with non-zero input. These equations are important results,
and students who are interested in a further study of control systems
would do well to memorize these equations.

## State-Transition Matrix

The state transition matrix, *e^At^*, is an important part of the
general state-space solutions for the time-invariant cases listed above.
Calculating this matrix exponential function is one of the very first
things that should be done when analyzing a new system, and the results
of that calculation will tell important information about the system in
question.

The matrix exponential can be calculated directly by using a
Taylor-Series expansion:

$$e^{At} = \sum_{n=0}^\infty \frac{(At)^n}{n!}$$

Also, we can attempt to diagonalize the matrix A into a **diagonal
matrix** or a **Jordan Canonical matrix**. The exponential of a diagonal
matrix is simply the diagonal elements individually raised to that
exponential. The exponential of a Jordan canonical matrix is slightly
more complicated, but there is a useful pattern that can be exploited to
find the solution quickly. Interested readers should read the relevant
passages in Engineering Analysis.

The state transition matrix, and matrix exponentials in general are very
important tools in control engineering.

### Diagonal Matrices

If a matrix is diagonal, the state transition matrix can be calculated
by raising each diagonal entry of the matrix raised as a power of *e*.

### Jordan Canonical Form

If the A matrix is in the Jordan Canonical form, then the matrix
exponential can be generated quickly using the following formula:

$$e^{Jt} = e^{\lambda t} \begin{bmatrix} 1 & t & \frac{1}{2!}t^2 & \cdots & \frac{1}{n!}t^n \\0 & 1 & t & \cdots & \frac{1}{(n-1)!}t^{n-1} \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & 0 & \cdots & 1\end{bmatrix}$$

Where *λ* is the eigenvalue (the value on the diagonal) of the
jordan-canonical matrix.

### Inverse Laplace Method

We can calculate the state-transition matrix (or any matrix exponential
function) by taking the following inverse Laplace transform:

$$e^{At} = \mathcal{L}^{-1}[(sI - A)^{-1}]$$

If A is a high-order matrix, this inverse can be difficult to solve.

If the A matrix is in the Jordan Canonical form, then the matrix
exponential can be generated quickly using the following formula:

`   `$e^{Jt} = e^{\lambda t} \begin{bmatrix} 1 & t & \frac{1}{2!}t^2 & \cdots & \frac{1}{n!}t^n \\0 & 1 & t & \cdots & \frac{1}{(n-1)!}t^{n-1} \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & 0 & \cdots & 1\end{bmatrix}$

Where λ is the eigenvalue (the value on the diagonal) of the
jordan-canonical matrix.

### Spectral Decomposition

If we know all the eigenvalues of *A*, we can create our transition
matrix *T*, and our inverse transition matrix *T^-1^* These matrices
will be the matrices of the right and left eigenvectors, respectively.
If we have both the left and the right eigenvectors, we can calculate
the state-transition matrix as:

$$e^{At} = \sum_{i = 1}^ne^{\lambda_i t} v_i w_i'$$

Note that *w~i~\'* is the transpose of the *i*th left-eigenvector, not
the derivative of it. We will discuss the concepts of \"eigenvalues\",
\"eigenvectors\", and the technique of spectral decomposition in more
detail in a later chapter.

### Cayley-Hamilton Theorem

The **Cayley-Hamilton Theorem** can also be used to find a solution for
a matrix exponential. For any eigenvalue of the system matrix *A*, *λ*,
we can show that the two equations are equivalent:

$$e^{\lambda t} = a_0 + a_1 \lambda t + a_2 \lambda^2t^2 + \cdots + a_{n-1}\lambda^{n-1}t^{n-1}$$

Once we solve for the coefficients of the equation, *a*, we can then
plug those coefficients into the following equation:

$$e^{At} = a_0I + a_1 A t + a_2 A^2 t^2 + \cdots + a_{n-1} A^{n-1} t^{n-1}$$

### Example: Off-Diagonal Matrix

### Example: Sympy Calculation

### Example: MATLAB Calculation

### Example: Multiple Methods in MATLAB

he:תורת הבקרה/פתרון משוואת המצב עבור מערכת קבועה
בזמן


# Control Systems/Time Variant System Solutions

## General Time Variant Solution

The state-space equations can be solved for time-variant systems, but
the solution is significantly more complicated than the time-invariant
case. Our time-variant state equation is given as follows:

$$x'(t) = A(t)x(t) + B(t)u(t)$$

We can say that the general solution to time-variant state-equation is
defined as:

$$x(t) = \phi(t, t_0)x(t_0) + \int_{t_0}^{t} \phi(t,\tau)B(\tau)u(\tau)d\tau$$

The function $\phi$ is called the **state-transition matrix**, because
it (like the matrix exponential from the time-invariant case) controls
the change for states in the state equation. However, unlike the
time-invariant case, we cannot define this as a simple exponential. In
fact, $\phi$ can\'t be defined in general, because it will actually be a
different function for every system. However, the state-transition
matrix does follow some basic properties that we can use to determine
the state-transition matrix.

In a time-variant system, the general solution is obtained when the
state-transition matrix is determined. For that reason, the first thing
(and the most important thing) that we need to do here is find that
matrix. We will discuss the solution to that matrix below.

### State Transition Matrix

The state transition matrix $\phi$ is not completely unknown, it must
always satisfy the following relationships:

$$\frac{\partial \phi(t, t_0)}{\partial t} = A(t)\phi(t, t_0)$$

$$\phi(\tau, \tau) = I$$

And $\phi$ also must have the following properties:

:   {\| class=\"wikitable\"

\|- \|1.\|\|$\phi(t_2, t_1)\phi(t_1, t_0) = \phi(t_2, t_0)$ \|-
\|2.\|\|$\phi^{-1}(t, \tau) = \phi(\tau, t)$ \|-
\|3.\|\|$\phi^{-1}(t, \tau)\phi(t, \tau) = I$ \|-
\|4.\|\|$\frac{d\phi(t_0, t_0)}{dt} = A(t)$ \|}

If the system is time-invariant, we can define $\phi$ as:

$$\phi(t, t_0) = e^{A(t - t_0)}$$

The reader can verify that this solution for a time-invariant system
satisfies all the properties listed above. However, in the time-variant
case, there are many different functions that may satisfy these
requirements, and the solution is dependent on the structure of the
system. The state-transition matrix must be determined before analysis
on the time-varying solution can continue. We will discuss some of the
methods for determining this matrix below.

## Time-Variant, Zero Input

As the most basic case, we will consider the case of a system with zero
input. If the system has no input, then the state equation is given as:

$$x'(t) = A(t)x(t)$$

And we are interested in the response of this system in the time
interval T = (a, b). The first thing we want to do in this case is find
a **fundamental matrix** of the above equation. The fundamental matrix
is related

### Fundamental Matrix

Given the equation:

$$x'(t) = A(t)x(t)$$

The solutions to this equation form an *n*-dimensional vector space in
the interval T = (a, b). Any set of *n* linearly-independent solutions
{x~1~, x~2~, \..., x~n~} to the equation above is called a **fundamental
set** of solutions.

A **fundamental matrix FM** is formed by creating a matrix out of the
*n* fundamental vectors. We will denote the fundamental matrix with a
script capital X:

$$\mathcal{X} = \begin{bmatrix}x_1 & x_2 & \cdots & x_n\end{bmatrix}$$

The fundamental matrix will satisfy the state equation:

$$\mathcal{X}'(t) = A(t)\mathcal{X}(t)$$

Also, *any matrix that solves this equation can be a fundamental matrix*
if and only if the determinant of the matrix is non-zero for all time
*t* in the interval T. The determinant must be non-zero, because we are
going to use the inverse of the fundamental matrix to solve for the
state-transition matrix.

### State Transition Matrix

Once we have the fundamental matrix of a system, we can use it to find
the state transition matrix of the system:

$$\phi(t, t_0) = \mathcal{X}(t)\mathcal{X}^{-1}(t_0)$$

The inverse of the fundamental matrix exists, because we specify in the
definition above that it must have a non-zero determinant, and therefore
must be non-singular. The reader should note that this is only one
possible method for determining the state transition matrix, and we will
discuss other methods below.

### Example: 2-Dimensional System

{e\^{-2t}}`</math>`{=html}$= \begin{bmatrix} {e}^{t}&-\frac{1}{2}\,{e}^{3t}\\0&{e}^{t}\end{bmatrix}$

The state-transition matrix is given by:

$$\phi(t, t_0) = \mathcal{X}(t)\mathcal{X}^{-1}(t_0) = \begin{bmatrix}e^{-t} & -\frac{1}{2} e^{t} \\ 0 & e^{-t}\end{bmatrix} \begin{bmatrix} {e}^{t_0}&\frac{1}{2}\,{e}^{3t_0}\\0&{e}^{t_0}\end{bmatrix}$$

$$\phi(t, t_0) = \begin{bmatrix} e^{-t + t_0} & \frac{1}{2}(e^{t + t_0} - e^{-t + 3t_0}) \\ 0 & e^{-t+t_0}\end{bmatrix}$$}}

### Other Methods

There are other methods for finding the state transition matrix besides
having to find the fundamental matrix.

Method 1:If A(t) is triangular (upper or lower triangular), the state transition matrix can be determined by sequentially integrating the individual rows of the state equation.

```{=html}
<!-- -->
```

Method 2:If for every τ and t, the state matrix commutes as follows:

:

    :   $A(t)\left[\int_{\tau}^{t}A(\zeta)d\zeta\right]=\left[\int_{\tau}^{t}A(\zeta)d\zeta\right]A(t)$

:   Then the state-transition matrix can be given as:
    $$\phi(t, \tau) = e^{\int_\tau^tA(\zeta)d\zeta}$$

:   The state transition matrix will commute as described above if any
    of the following conditions are true:
    1.  A is a constant matrix (time-invariant)
    2.  A is a diagonal matrix
    3.  If $A = \bar{A}f(t)$, where $\bar{A}$ is a constant matrix, and
        f(t) is a scalar-valued function (not a matrix).

:   If none of the above conditions are true, then you must use **method
    3**.

Method 3:If A(t) can be decomposed as the following sum:

:

    :   $A(t) = \sum_{i = 1}^n M_i f_i(t)$

:   Where *M*~i~ is a constant matrix such that M~i~M~j~ = M~j~M~i~, and
    *f*~i~ is a scalar-valued function. If A(t) can be decomposed in
    this way, then the state-transition matrix can be given as:
    $$\phi(t, \tau) = \prod_{i=1}^n e^{M_i \int_\tau^t f_i(\theta)d\theta}$$

It will be left as an exercise for the reader to prove that if A(t) is
time-invariant, that the equation in **method 2** above will reduce to
the state-transition matrix $e^{A(t-\tau)}$.

### Example: Using Method 3

e\^{\\begin{bmatrix}0 & t-\\tau \\\\ -t+\\tau &
0\\end{bmatrix}}`</math>`{=html}

The first term is a diagonal matrix, and the solution to that matrix
function is all the individual elements of the matrix raised as an
exponent of *e*. The second term can be decomposed as:

$$e^{\begin{bmatrix}0 & t-\tau \\ -t+\tau & 0\end{bmatrix}} = e^{\begin{bmatrix}0 & 1 \\ -1 & 0\end{bmatrix}(t-\tau)} = \begin{bmatrix}\cos(t-\tau) & \sin(t-\tau)\\ -\sin(t-\tau) & \cos(t-\tau)\end{bmatrix}$$

The final solution is given as:

$$\phi(t, \tau) =$$$\begin{bmatrix}e^{\frac{1}{2}(t^2-\tau^2)} & 0 \\ 0 & e^{\frac{1}{2}(t^2-\tau^2)}\end{bmatrix}\begin{bmatrix}\cos(t-\tau) & \sin(t-\tau)\\ -\sin(t-\tau) & \cos(t-\tau)\end{bmatrix}$$= \begin{bmatrix}e^{\frac{1}{2}(t^2-\tau^2)}\cos(t-\tau) & e^{\frac{1}{2}(t^2-\tau^2)}\sin(t-\tau)\\ -e^{\frac{1}{2}(t^2-\tau^2)}\sin(t-\tau) & e^{\frac{1}{2}(t^2-\tau^2)}\cos(t-\tau)\end{bmatrix}$}}

## Time-Variant, Non-zero Input

If the input to the system is not zero, it turns out that all the
analysis that we performed above still holds. We can still construct the
fundamental matrix, and we can still represent the system solution in
terms of the state transition matrix $\phi$.

We can show that the general solution to the state-space equations is
actually the solution:

$$x(t) = \phi(t, t_0)x(t_0) + \int_{t_0}^{t} \phi(t,\tau)B(\tau)u(\tau)d\tau$$


# Control Systems/Digital State Space

## Digital Systems

Digital systems, expressed previously as difference equations or
Z-Transform transfer functions, can also be used with the state-space
representation. All the same techniques for dealing with analog systems
can be applied to digital systems with only minor changes.

## Digital Systems

For digital systems, we can write similar equations using discrete data
sets:

$$x[k + 1] = Ax[k] + Bu[k]$$

$$y[k] = Cx[k] + Du[k]$$

### Zero-Order Hold Derivation

If we have a continuous-time state equation:

$$x'(t) = Ax(t) + Bu(t)$$

We can derive the digital version of this equation that we discussed
above. We take the Laplace transform of our equation:

$$X(s) = (sI - A)^{-1}Bu(s) + (sI - A)^{-1}x(0)$$

Now, taking the inverse Laplace transform gives us our time-domain
system, keeping in mind that the inverse Laplace transform of the *(sI -
A)* term is our state-transition matrix, Φ:

$$x(t) = \mathcal{L}^{-1}(X(s)) = \Phi(t - t_0)x(0) + \int_{t_0}^t\Phi(t - \tau)Bu(\tau)d\tau$$

Now, we apply a zero-order hold on our input, to make the system
digital. Notice that we set our start time *t~0~ = kT*, because we are
only interested in the behavior of our system during a single sample
period:

$$u(t) = u(kT), kT \le t \le (k+1)T$$

$$x(t) = \Phi(t, kT)x(kT) + \int_{kT}^t \Phi(t, \tau)Bd\tau u(kT)$$

We were able to remove *u(kT)* from the integral because it did not rely
on τ. We now define a new function, Γ, as follows:

$$\Gamma(t, t_0) = \int_{t_0}^t \Phi(t, \tau)Bd\tau$$

Inserting this new expression into our equation, and setting *t = (k +
1)T* gives us:

$$x((k + 1)T) = \Phi((k+1)T, kT)x(kT) + \Gamma((k+1)T, kT)u(kT)$$

Now Φ(T) and Γ(T) are constant matrices, and we can give them new names.
The *d* subscript denotes that they are digital versions of the
coefficient matrices:

$$A_d = \Phi((k+1)T, kT)$$

$$B_d = \Gamma((k+1)T, kT)$$

We can use these values in our state equation, converting to our bracket
notation instead:

$$x[k + 1] = A_dx[k] + B_du[k]$$

## Relating Continuous and Discrete Systems

Continuous and discrete systems that perform similarly can be related
together through a set of relationships. It should come as no surprise
that a discrete system and a continuous system will have different
characteristics and different coefficient matrices. If we consider that
a discrete system is the same as a continuous system, except that it is
sampled with a sampling time T, then the relationships below will hold.
The process of converting an analog system for use with digital hardware
is called **discretization**. We\'ve given a basic introduction to
discretization already, but we will discuss it in more detail here.

### Discrete Coefficient Matrices

Of primary importance in discretization is the computation of the
associated coefficient matrices from the continuous-time counterparts.
If we have the continuous system *(A, B, C, D)*, we can use the
relationship *t = kT* to transform the state-space solution into a
sampled system:

$$x(kT) = e^{AkT}x(0) + \int_0^{kT} e^{A(kT - \tau)}Bu(\tau)d\tau$$

$$x[k] = e^{AkT}x[0] + \int_0^{kT} e^{A(kT - \tau)}Bu(\tau)d\tau$$

Now, if we want to analyze the *k+1* term, we can solve the equation
again:

$$x[k+1] = e^{A(k+1)T}x[0] + \int_0^{(k+1)T} e^{A((k+1)T - \tau)}Bu(\tau)d\tau$$

Separating out the variables, and breaking the integral into two parts
gives us:

$$x[k+1] = e^{AT}e^{AkT}x[0] + \int_0^{kT}e^{AT}e^{A(kT - \tau)}Bu(\tau)d\tau + \int_{kT}^{(k+1)T} e^{A(kT + T - \tau)}Bu(\tau)d\tau$$

If we substitute in a new variable *β = (k + 1)T + τ*, and if we see the
following relationship:

$$e^{AkT}x[0] = x[k]$$

We get our final result:

$$x[k+1] = e^{AT}x[k] + \left(\int_0^T e^{A\alpha}d\alpha\right)Bu[k]$$

Comparing this equation to our regular solution gives us a set of
relationships for converting the continuous-time system into a
discrete-time system. Here, we will use \"d\" subscripts to denote the
system matrices of a discrete system, and we will use a \"c\" subscript
to denote the system matrices of a continuous system.

:   {\| class=\"wikitable\"

\|- \|$A_d = e^{A_cT}$ \|- \|$B_d = \int_0^Te^{A_c\tau}d\tau B_c$ \|-
\|$C_d = C_c$ \|- \|$D_d = D_c$ \|}

If the A~c~ matrix is nonsingular, then we can find its inverse and
instead define B~d~ as:

$$B_d = A_c^{-1}(A_d - I)B_c$$

The differences in the discrete and continuous matrices are due to the
fact that the underlying equations that describe our systems are
different. Continuous-time systems are represented by linear
differential equations, while the digital systems are described by
difference equations. High order terms in a difference equation are
delayed copies of the signals, while high order terms in the
differential equations are derivatives of the analog signal.

If we have a complicated analog system, and we would like to implement
that system in a digital computer, we can use the above transformations
to make our matrices conform to the new paradigm.

### Notation

Because the coefficient matrices for the discrete systems are computed
differently from the continuous-time coefficient matrices, and because
the matrices technically represent different things, it is not uncommon
in the literature to denote these matrices with different variables. For
instance, the following variables are used in place of *A* and *B*
frequently:

$$\Omega = A_d$$

$$R = B_d$$

These substitutions would give us a system defined by the ordered
quadruple *(Ω, R, C, D)* for representing our equations.

As a matter of notational convenience, we will use the letters *A* and
*B* to represent these matrices throughout the rest of this book.

## Converting Difference Equations

## Solving for x\[n\]

We can find a general time-invariant solution for the discrete time
difference equations. Let us start working up a pattern. We know the
discrete state equation:

$$x[n+1] = Ax[n] + Bu[n]$$

Starting from time *n = 0*, we can start to create a pattern:

$$x[1] = Ax[0] + Bu[0]$$

$$x[2] = Ax[1] + Bu[1] = A^2x[0] + ABu[0] + Bu[1]$$

$$x[3] = Ax[2] + Bu[2] = A^3x[0] + A^2Bu[0] + ABu[1] + Bu[2]$$

With a little algebraic trickery, we can reduce this pattern to a single
equation:

$$x[n] = A^nx[n_0] + \sum_{m=0}^{n-1}A^{n-1-m}Bu[m]$$

Substituting this result into the output equation gives us:

$$y[n] = CA^nx[n_0] + \sum_{m=0}^{n-1}CA^{n-1-m}Bu[m] + Du[n]$$

## Time Variant Solutions

If the system is time-variant, we have a general solution that is
similar to the continuous-time case:

$$x[n] = \phi[n, n_0]x[n_0] + \sum_{m = n_0}^{n-1} \phi[n, m+1]B[m]u[m]$$

$$y[n] = C[n]\phi[n, n_0]x[n_0] + C[n]\sum_{m = n_0}^{n-1} \phi[n, m+1]B[m]u[m] + D[n]u[n]$$

Where φ, the **state transition matrix**, is defined in a similar manner
to the state-transition matrix in the continuous case. However, some of
the properties in the discrete time are different. For instance, the
inverse of the state-transition matrix does not need to exist, and in
many systems it does not exist.

### State Transition Matrix

The discrete time state transition matrix is the unique solution of the
equation:

$$\phi[k+1, k_0] = A[k] \phi[k, k_0]$$

Where the following restriction must hold:

$$\phi[k_0, k_0] = I$$

From this definition, an obvious way to calculate this state transition
matrix presents itself:

$$\phi[k, k_0] = A[k - 1]A[k-2]A[k-3]\cdots A[k_0]$$

Or,

$$\phi[k, k_0] = \prod_{m = 1}^{k-k_0}A[k-m]$$

## MATLAB Calculations

MATLAB is a computer program, and therefore calculates all systems using
digital methods. The MATLAB function **lsim** is used to simulate a
continuous system with a specified input. This function works by calling
the **c2d**, which converts a system *(A, B, C, D)* into the equivalent
discrete system. Once the system model is discretized, the function
passes control to the **dlsim** function, which is used to simulate
discrete-time systems with the specified input.

Because of this, simulation programs like MATLAB are subjected to
round-off errors associated with the discretization process.


# Control Systems/Eigenvalues and Eigenvectors

## Eigenvalues and Eigenvectors

The eigenvalues and eigenvectors of the system matrix play a key role in
determining the response of the system. It is important to note that
only square matrices have eigenvalues and eigenvectors associated with
them. Non-square matrices cannot be analyzed using the methods below.

The word \"eigen\" comes from German and means \"own\" as in
\"characteristic\", so this chapter could also be called
\"Characteristic values and characteristic vectors\". The terms
\"Eigenvalues\" and \"Eigenvectors\" are most commonly used. Eigenvalues
and Eigenvectors have a number of properties that make them valuable
tools in analysis, and they also have a number of valuable relationships
with the matrix from which they are derived. Computing the eigenvalues
and the eigenvectors of the system matrix is one of the most important
things that should be done when beginning to analyze a system matrix,
second only to calculating the matrix exponential of the system matrix.

The eigenvalues and eigenvectors of the system determine the
relationship between the individual system state variables (the members
of the *x* vector), the response of the system to inputs, and the
stability of the system. Also, the eigenvalues and eigenvectors can be
used to calculate the matrix exponential of the system matrix through
spectral decomposition. The remainder of this chapter will discuss
eigenvalues, eigenvectors, and the ways that they affect their
respective systems.

## Characteristic Equation

The characteristic equation of the system matrix A is given as:

$$Av = \lambda v$$

Where λ are scalar values called the **eigenvalues**, and *v* are the
corresponding **eigenvectors**. To solve for the eigenvalues of a
matrix, we can take the following determinant:

$$|A - \lambda I| = 0$$

To solve for the eigenvectors, we can then add an additional term, and
solve for *v*:

$$(A - \lambda I)v = 0$$

Another value worth finding are the **left eigenvectors** of a system,
defined as *w* in the modified characteristic equation:

$$wA = \lambda w$$

For more information about eigenvalues, eigenvectors, and left
eigenvectors, read the appropriate sections in the following books:

-   Linear Algebra
-   Engineering Analysis

### Diagonalization

If the matrix *A* has a complete set of distinct eigenvalues, the matrix
can be **diagonalized**. A diagonal matrix is a matrix that only has
entries on the diagonal, and all the rest of the entries in the matrix
are zero. We can define a **transformation matrix**, *T*, that satisfies
the diagonalization transformation:

$$A = TDT^{-1}$$

Which in turn will satisfy the relationship:

$$e^{At} = Te^{Dt}T^{-1}$$

The right-hand side of the equation may look more complicated, but
because*D*is a diagonal matrix here (not to be confused with the
feed-forward matrix from the output equation), the calculations are much
easier.

We can define the transition matrix, and the inverse transition matrix
in terms of the eigenvectors and the left eigenvectors:

$$T = \begin{bmatrix} v_1 & v_2 & v_3 & \cdots & v_n\end{bmatrix}$$

$$T^{-1} = \begin{bmatrix} w_1' \\w_2' \\ w_3' \\\vdots \\ w_n'\end{bmatrix}$$

We will further discuss the concept of diagonalization later in this
chapter.

## Exponential Matrix Decomposition

A matrix exponential can be decomposed into a sum of the eigenvectors,
eigenvalues, and left eigenvectors, as follows:

$$e^{At} = \sum_{i = 1}^n e^{\lambda_i t}v_i w_i'$$

Notice that this equation only holds in this form if the matrix A has a
complete set of n distinct eigenvalues. Since w\'~i~ is a row vector,
and x(0) is a column vector of the initial system states, we can combine
those two into a scalar coefficient α:

$$e^{At} x(t_0) = \sum_{i = 1}^n \alpha_i e^{\lambda_i t} v_i$$

Since the state transition matrix determines how the system responds to
an input, we can see that the system eigenvalues and eigenvectors are a
key part of the system response. Let us plug this decomposition into the
general solution to the state equation:

$$x(t) = \sum_{i = 1}^n \alpha_i e^{\lambda_i t} v_i + \sum_{i = 1}^n \int_0^t e^{\lambda_i (t-\tau)}v_i w_i' Bu(\tau) d\tau$$

We will talk about this equation in the following sections.

### State Relationship

As we can see from the above equation, the individual elements of the
state vector *x(t)* cannot take arbitrary values, but they are instead
related by weighted sums of multiples of the systems right-eigenvectors.

### Decoupling

If a system can be designed such that the following relationship holds
true:

$$w_i'B = 0$$

then the system response from that particular eigenvalue will not be
affected by the system input *u*, and we say that the system has been
**decoupled**. Such a thing is difficult to do in practice.

### Condition Number

With every matrix there is associated a particular number called the
**condition number** of that matrix. The condition number tells a number
of things about a matrix, and it is worth calculating. The condition
number, *k*, is defined as:

$$k = \frac{\|w_i\|\|v_i\|}{|w_i'v_i|}$$

Systems with smaller condition numbers are better, for a number of
reasons:

1.  Large condition numbers lead to a large transient response of the
    system
2.  Large condition numbers make the system eigenvalues more sensitive
    to changes in the system.

We will discuss the issue of **eigenvalue sensitivity** more in a later
section.

### Stability

We will talk about stability at length in later chapters, but is a good
time to point out a simple fact concerning the eigenvalues of the
system. Notice that if the eigenvalues of the system matrix A are
*positive*, or (if they are complex) that they have positive real parts,
that the system state (and therefore the system output, scaled by the C
matrix) will approach infinity as time *t* approaches infinity. In
essence, if the eigenvalues are positive, the system will not satisfy
the condition of BIBO stability, and will therefore become *unstable*.

Another factor that is worth mentioning is that a manufactured system
*never exactly matches the system model*, and there will always been
inaccuracies in the specifications of the component parts used, *within
a certain tolerance*. As such, the system matrix will be slightly
different from the mathematical model of the system (although good
systems will not be severely different), and therefore the eigenvalues
and eigenvectors of the system will not be the same values as those
derived from the model. These facts give rise to several results:

1.  Systems with high *condition numbers* may have eigenvalues that
    differ by a large amount from those derived from the mathematical
    model. This means that the system response of the physical system
    may be very different from the intended response of the model.
2.  Systems with high condition numbers may become *unstable* simply as
    a result of inaccuracies in the component parts used in the
    manufacturing process.

For those reasons, the system eigenvalues and the condition number of
the system matrix are highly important variables to consider when
analyzing and designing a system. We will discuss the topic of stability
in more detail in later chapters.

## Non-Unique Eigenvalues

The decomposition above only works if the matrix *A* has a full set of n
distinct eigenvalues (and corresponding eigenvectors). If *A* does not
have *n* distinct eigenvectors, then a set of **generalized
eigenvectors** need to be determined. The generalized eigenvectors will
produce a similar matrix that is in **Jordan canonical form**, not the
diagonal form we were using earlier.

### Generalized Eigenvectors

Generalized eigenvectors can be generated using the following equation:

$$(A - \lambda I) v_{n+1} = v_n$$

if *d* is the number of times that a given eigenvalue is repeated, and
*p* is the number of unique eigenvectors derived from those eigenvalues,
then there will be *q = d - p* generalized eigenvectors. Generalized
eigenvectors are developed by plugging in the regular eigenvectors into
the equation above (*v~n~*). Some regular eigenvectors might not produce
any non-trivial generalized eigenvectors. Generalized eigenvectors may
also be plugged into the equation above to produce additional
generalized eigenvectors. It is important to note that the generalized
eigenvectors form an ordered series, and they must be kept in order
during analysis or the results will not be correct.

### Example: One Repeated Set

### Example: Two Repeated Sets

### Jordan Canonical Form

If a matrix has a complete set of distinct eigenvectors, the transition
matrix *T* can be defined as the matrix of those eigenvectors, and the
resultant transformed matrix will be a diagonal matrix. However, if the
eigenvectors are not unique, and there are a number of generalized
eigenvectors associated with the matrix, the transition matrix *T* will
consist of the ordered set of the regular eigenvectors and generalized
eigenvectors. The regular eigenvectors that did not produce any
generalized eigenvectors (if any) should be first in the order, followed
by the eigenvectors that did produce generalized eigenvectors, and the
generalized eigenvectors that they produced (in appropriate sequence).

Once the *T* matrix has been produced, the matrix can be transformed by
it and it\'s inverse:

$$A = T^{-1}JT$$

The *J* matrix will be a **Jordan block matrix**. The format of the
Jordan block matrix will be as follows:

$$J = \begin{bmatrix}
                      D & 0 & \cdots & 0 \\
                      0 & J_1 & \cdots & 0 \\
                      \vdots & \vdots &\ddots & \vdots \\
                      0 & 0 & \cdots & J_n
       \end{bmatrix}$$

Where *D* is the diagonal block produced by the regular eigenvectors
that are not associated with generalized eigenvectors (if any). The
*J~n~* blocks are standard Jordan blocks with a size corresponding to
the number of eigenvectors/generalized eigenvectors in each sequence. In
each *J~n~* block, the eigenvalue associated with the regular
eigenvector of the sequence is on the main diagonal, and there are 1\'s
in the sub-diagonal.

### System Response

## Equivalence Transformations

If we have a non-singular *n × n* matrix *P*, we can define a
transformed vector \"x bar\" as:

$$\bar{x} = Px$$

We can transform the entire state-space equation set as follows:

$$\bar{x}'(t) = \bar{A}\bar{x}(t) + \bar{B}u(t)$$

$$\bar{y}(t) = \bar{C}\bar{x}(t) + \bar{D}u(t)$$

Where:

:   {\| class=\"wikitable\"

\|- \|$\bar{A} = PAP^{-1}$ \|- \|$\bar{B} = PB$ \|-
\|$\bar{C} = CP^{-1}$ \|- \|$\bar{D} = D$ \|}

We call the matrix *P* the **equivalence transformation** between the
two sets of equations.

It is important to note that the **eigenvalues** of the matrix *A*
(which are of primary importance to the system) do not change under the
equivalence transformation. The eigenvectors of *A*, and the
eigenvectors of $\bar{A}$ are related by the matrix *P*.

### Lyapunov Transformations

The transformation matrix *P* is called a **Lyapunov Transformation** if
the following conditions hold:

-   *P(t)* is nonsingular.
-   *P(t)* and *P\'(t)* are continuous
-   *P(t)* and the inverse transformation matrix *P^-1^(t)* are finite
    for all *t*.

If a system is time-variant, it can frequently be useful to use a
Lyapunov transformation to convert the system to an equivalent system
with a constant *A* matrix. This is not always possible in general,
however it is possible if the *A(t)* matrix is periodic.

### System Diagonalization

If the *A* matrix is time-invariant, we can construct the matrix *V*
from the eigenvectors of *A*. The *V* matrix can be used to transform
the *A* matrix to a diagonal matrix. Our new system becomes:

$$Vx'(t) = VAV^{-1}Vx(t) + VBu(t)$$

$$y(t) = CV^{-1}Vx(t) + Du(t)$$

Since our system matrix is now diagonal (or Jordan canonical), the
calculation of the state-transition matrix is simplified:

$$e^{VAV^{-1}} = \Lambda$$

Where Λ is a diagonal matrix.

### MATLAB Transformations

The MATLAB function **ss2ss** can be used to apply an equivalence
transformation to a system. If we have a set of matrices *A*, *B*, *C*
and *D*, we can create equivalent matrices as such:

`[Ap, Bp, Cp, Dp] = ss2ss(A, B, C, D, p);`

Where *p* is the equivalence transformation matrix.