## Time Delays in Linear Systems

Use the following model properties to represent time delays in linear systems.

`InputDelay`

,`OutputDelay`

— Time delays at system inputs or outputs`ioDelay`

,`InternalDelay`

— Time delays that are internal to the system

In discrete-time models, these properties are constrained to integer values that
represent delays expressed as integer multiples of the sample time. To approximate
discrete-time models with delays that are a fractional multiple of the sample time, use
`thiran`

.

### First Order Plus Dead Time Model

This example shows how to create a first order plus dead time model using the
`InputDelay`

or `OutputDelay`

properties of
`tf`

.

To create the following first-order transfer function with a 2.1 s time delay:

$$G\left(s\right)={e}^{-2.1s}\frac{1}{s+10},$$

enter:

`G = tf(1,[1 10],'InputDelay',2.1)`

where `InputDelay`

specifies the delay at the input of the
transfer function.

For SISO transfer functions, a delay at the input is equivalent to a delay at the output. Therefore, the following command creates the same transfer function:

`G = tf(1,[1 10],'OutputDelay',2.1)`

Use dot notation to examine or change the value of a time delay. For example, change the time delay to 3.2 as follows:

G.OutputDelay = 3.2;

To see the current value, enter:

G.OutputDelay ans = 3.2000

**Tip**

An alternative way to create a model with a time delay is to specify the
transfer function with the delay as an expression in
*s*:

Create a transfer function model for the variable

*s*.`s = tf('s');`

Specify

*G*(*s*) as an expression in*s*.G = exp(-2.1*s)/(s+10);

### Input and Output Delay in State-Space Model

This example shows how to create state-space models with delays at the inputs and
outputs, using the `InputDelay`

or `OutputDelay`

properties of `ss`

.

Create a state-space model describing the following one-input, two-output system:

$$\begin{array}{l}\frac{dx\left(t\right)}{dt}=-2x\left(t\right)+3u\left(t-1.5\right)\\ y\left(t\right)=\left[\begin{array}{c}x\left(t-0.7\right)\\ -x\left(t\right)\end{array}\right].\end{array}$$

This system has an input delay of 1.5. The first output has an output delay of 0.7, and the second output is not delayed.

**Note**

In contrast to SISO transfer functions, input delays are not equivalent to
output delays for state-space models. Shifting a delay from input to output in a
state-space model requires introducing a time shift in the model states. For
example, in the model of this example, defining *T* = *t* – 1.5 and *X*(*T*) = *x*(*T* + 1.5) results in the following equivalent system:

$$\begin{array}{l}\frac{dX\left(T\right)}{dT}=-2X\left(T\right)+3u\left(T\right)\\ y\left(T\right)=\left[\begin{array}{c}X\left(T-2.2\right)\\ -X\left(T-1.5\right)\end{array}\right].\end{array}$$

All of the time delays are on the outputs, but the new state variable
*X* is time-shifted relative to the original state variable
*x*. Therefore, if your states have physical meaning, or if
you have known state initial conditions, consider carefully before shifting time
delays between inputs and outputs.

To create this system:

Define the state-space matrices.

A = -2; B = 3; C = [1;-1]; D = 0;

Create the model.

G = ss(A,B,C,D,'InputDelay',1.5,'OutputDelay',[0.7;0])

`G`

is a `ss`

model.

**Tip**

Use `delayss`

to create state-space
models with more general combinations of input, output, and state delays, of the
form:

$$\begin{array}{l}\frac{dx}{dt}=Ax(t)+Bu(t)+{\displaystyle \sum _{j=1}^{N}(Ajx(t-tj)+Bju(t-tj))}\\ y(t)=Cx(t)+Du(t)+{\displaystyle \sum _{j=1}^{N}(Cjx(t-tj)+Dju(t-tj))}\end{array}$$

### Transport Delay in MIMO Transfer Function

This example shows how to create a MIMO transfer function with different transport delays for each input-output (I/O) pair.

Create the MIMO transfer function:

$$H\left(s\right)=\left[\begin{array}{cc}{e}^{-0.1}\frac{2}{s}& {e}^{-0.3}\frac{s+1}{s+10}\\ 10& {e}^{-0.2}\frac{s-1}{s+5}\end{array}\right].$$

Time delays in MIMO systems can be specific to each I/O pair, as in this example.
You cannot use `InputDelay`

and `OutputDelay`

to
model I/O-specific transport delays. Instead, use `ioDelay`

to
specify the transport delay across each I/O pair.

To create this MIMO transfer function:

Create a transfer function model for the variable

`s`

.`s = tf('s');`

Use the variable

`s`

to specify the transfer functions of`H`

without the time delays.H = [2/s (s+1)/(s+10); 10 (s-1)/(s+5)];

Specify the

`ioDelay`

property of`H`

as an array of values corresponding to the transport delay for each I/O pair.H.IODelay = [0.1 0.3; 0 0.2];

`H`

is a two-input, two-output `tf`

model.
Each I/O pair in `H`

has the time delay specified by the
corresponding entry in `tau`

.

### Discrete-Time Transfer Function with Time Delay

This example shows how to create a discrete-time transfer function with a time delay.

In discrete-time models, a delay of one sampling period corresponds to a factor of $${z}^{-1}$$ in the transfer function. For example, the following transfer function represents a discrete-time SISO system with a delay of 25 sampling periods.

$$H\left(z\right)={z}^{-25}\frac{2}{z-0.95}.$$

To represent integer delays in discrete-time systems in MATLAB®, set the `'InputDelay'`

property of the model object to an integer value. For example, the following command creates a `tf`

model representing $$H\left(z\right)$$ with a sampling time of 0.1 s.

`H = tf(2,[1 -0.95],0.1,'InputDelay',25)`

H = 2 z^(-25) * -------- z - 0.95 Sample time: 0.1 seconds Discrete-time transfer function.

If system has a time delay that is not an integer multiple of the sampling time, you can use the `thiran`

command to approximate the fractional portion of the time delay with an all-pass filter. See Time-Delay Approximation.