| Control System Toolbox™ | ![]() |
You can use Control System Toolbox tools to perform accurate analysis of LTI systems with time delays. Such systems are common, particularly in process control applications. You can create, manipulate, and analyze any LTI model with a finite number of delays.
Delays can occur at
Inputs
Outputs
Between individual I/O pairs
Internally (for example, inside a feedback loop)
Transfer function (TF), zero-pole-gain (ZPK), and frequency response data (FRD) objects have three properties for modeling delays:
InputDelay — Specify delays at the inputs.
OutputDelay — Specify delays at the outputs.
IODelay — Specify independent transport delays for individual I/O pairs.
State-space (SS) objects have three properties as well:
InputDelay — Specify delays at the inputs.
OuputDelay — Specify delays at the outputs.
InternalDelay — Keep track of delays when combining models with internal/external delays or closing feedback loops.
Since SS objects can keep track of internal delays, state-space representation is best suited for modeling and analyzing delay effects in control systems.
The simplest type of delays are delays in the input and output channels. The InputDelay and OutputDelay properties let you specify such delays Use theInputDelay property to specify delays at the model inputs and the OutputDelay property to specify delays at the outputs. For example, you can specify a first-order transfer function with deadtime (which is common in process control applications):
![]()
s = tf('s');
sys = 1/(s+1);
sys.InputDelay = 2
Transfer function:
1
exp(-2*s) * -----
s + 1
creates a system with a 2 s. delay.
Likewise, use the OutputDelay property to specify output delays. For example:
sys.OuputDelay = 1.5;
You can also specify state-space models with delays at the inputs or outputs. For example,

can be specified with
sys1=ss(-2,1,7,0,'InputDelay',1.8)
a =
x1
x1 -2
b =
u1
x1 1
c =
x1
y1 7
d =
u1
y1 0
Input delays (listed by channel): 1.8
Continuous-time model.The model has an input delay of 1.8 s. Similarly, to create the model:

with a 1.8 s. delay at the output, use:
sys2=ss(-2,1,7,0,'OutputDelay', 1.8);
sys2.OutputDelay
ans =
1.8000Compare the step response of the two systems:
step(sys1,sys2);
grid
legend('System with input delay','System with output delay')

The response is exactly the same for both systems. The difference lies in state trajectories. Since the y(t)'s are equal,
![]()
where x1 is the state of sys1, and x2 is the state of sys2.
You can also specify independent delays on each entry of a MIMO TF or ZPK model. Transport delays from a given input to a given output of a MIMO system are called I/O delays. For example, to create this 2-by-2 transfer function with four I/O delays:

Use exp to specify the delays and apply them to each entry:
s=tf('s'); % Laplace variable
sys= exp(-s*[0.5 1.2; 0.3 0.9]).* ...
[s/(s+2) 3/(s^2+5); 2/(s^2+2*s+7) (s+7)/(s+9)];
Transfer function from input 1 to output...
s
#1: exp(-0.5*s) * -----
s + 2
2
#2: exp(-0.3*s) * -------------
s^2 + 2 s + 7
Transfer function from input 2 to output...
3
#1: exp(-1.2*s) * -------
s^2 + 5
s + 7
#2: exp(-0.9*s) * -----
s + 9You could also have specified the delays by setting the ioDelay property.
s=tf('s');
sys= [s/(s+2) 3/(s^2+5); ...
2/(s^2+2*s+7) (s+7)/(s+9)];
tau = [0.1 0.2; 0.3 0.9]; % Create I/O delay matrix.
sys.ioDelay = tau; % Add I/O delays to sys.
You can retrieve the I/O delay values using the following:
sys.ioDelay
ans =
0.1000 0.2000
0.3000 0.9000Using the InputDelay, OutputDelay, and ioDelay properties, you can model simple processes with transport delays, but you cannot model more complex situations, like a feedback loop with delays. In addition to the InputDelay and OutputDelay properties, state-space (SS) models have an InternalDelay property, that lets you model interconnection of systems with input, output, or I/O delays, including feedback loops with delays. You can use this feature to accurately model and analyze arbitrary linear systems with delays. Internal delays can arise from the following:
Concatenating state-space models with input and output delays
Feeding back a delayed signal
Converting MIMO TF or ZPK models with I/O delays to state space
Using internal time delays, you can do the following:
In continuous time, generate approximate-free time and frequency simulations, since delays are no longer replaced by a Padé approximation. In continuous time, this allows for more accurate analysis of systems with long delays.
In discrete time, you can keep delays separate from other system dynamics. Delays are not replaced with poles at z=0, which boosts efficiency of time and frequency simulations for discrete-time systems with long delays.
Use most Control System Toolbox functions.
Test advanced control strategies for delayed systems. For example, you can implement and test an accurate model of a Smith predictor. See the Smith predictor demo.
See Inside Time Delay Models for more information about how internal delay are modeled.
Why are input, output, and I/O delays not enough to model systems? Consider the simple feedback loop with a 2 s. delay:

The closed-loop transfer function is
![]()
While the delay term in the numerator can be represented as an output delay, the delay term in the denominator cannot. In order to model the effect of the delay on the feedback loop, an additional property is needed to keep track of internal coupling between delays and ordinary dynamics.
Typically, state-space models with internal delays are not created by specifying A, B, C, and D matrices together with a set of internal delays. Rather, build such models by connecting simpler LTI models (some with I/O delays) in series, parallel, or feedback. There is no limitation on how many delays are involved and how the LTI models are connected. For example, consider the following control loop, where the plant is modeled as first-order plus dead time.

Using the state-space representation, you can derive model T for the closed-loop response from r to y and simulate it by
P = ss(5*exp(-3.4*s)/(s+1));
C = 0.1 * (1 + 1/(5*s));
T = feedback(P*C,1)
a =
x1 x2
x1 -1.5 0.32
x2 -0.3125 0
b =
u1
x1 0.2
x2 0.125
c =
x1 x2
y1 2.5 0
d =
u1
y1 0
(a,b,c,d values when setting all internal delays to zero)
Internal delays: 3.4
Review the following considerations when you work with models with internal delays:
The software converts model from TF representation to SS.
The software fully supports feedback loops. You can wrap a feedback loop around any system with delays.
When displaying the A, B, C, and D matrices, the software sets all delays to zero (creating a zero-order Padé approximation).
For some systems, setting delays to zero creates singular algebraic loops, which result in either improper or ill-defined, zero-delay approximations. For these systems, typing the command
sys returns only sizes for the matrices of a system named sys.
sys.a produces an error.
The limited display and the error do not imply a problem with the model sys itself.
You can create arbitrary linear systems with delays using combinations of state-space models and interconnection functions. Build complex models incrementally by interconnecting smaller models. You can decompose complex diagrams unless you have lumped delays (as in integral equations). After you create a system with internal delays, you can view and change the delays' values using dot notation. For example:
sys_delay.Internaldelay
ans =
1.5000You cannot modify the number of internal delays because they are structural properties of the model. You can, however, set the delays to 0 or change their values.
You can use the usual analysis commands (step, bode, margin, ...) to analyze systems with delays. The software makes no approximations when performing such analysis.
For example, use this code to see the closed-loop step response of T.
step(T)
grid, title('Closed-loop step response')

For more complicated interconnections, you can name the input and output signals of each block and use connect to automatically take care of the wiring. Suppose, for example, that you want to add feedforward to the control loop of the previous model.

You can derive the corresponding closed-loop model T by
F = 0.3/(s+4);
P.InputName = 'u'; P.OutputName = 'y';
C.InputName = 'e'; C.OutputName = 'uc';
F.InputName = 'r'; F.OutputName = 'uf';
Sum1 = sumblk('e','r','y','+-'); % e = r-y
Sum2 = sumblk('u','uf','uc','++'); % u = uf+uc
Tff = connect(P,C,F,Sum1,Sum2,'r','y');
and compare its response with the feedback only design.
step(T,'b',Tff,'r')
legend('No feedforward','Feedforward')
grid
title('Closed-loop step response with and without feedforward')

The time and frequency responses of delay systems can look odd and suspicious to those only familiar with delay-free LTI analysis. Time responses can behave chaotically, Bode plots can exhibit gain oscillations, etc. These are not software or numerical quirks but real features of such systems. Below are a few illustrations of these phenomena.
Gain ripple:
s=tf('s');
G = exp(-5*s)/(s+1);
T = feedback(ss(G),.5);
bodemag(T)

Gain oscillations:
G = ss(1) + 0.5 * exp(-3*s); bodemag(G)

Jagged step response:
G = exp(-s) * (0.8*s^2+s+2)/(s^2+s); T = feedback(ss(G),1); step(T)

Note the rearrivals (echoes) of the initial step function.
Chaotic response:
G = ss(1/(s+1)) + exp(-4*s); T = feedback(1,G); step(T)

You can use Control System Toolbox tools to model and analyze these and other strange-appearing artifacts of internal delays.
Most control design algorithms cannot handle time delays directly. For example, root locus, LQG, pole placement, etc., will not work properly if time delays are present. A common technique is to replace delays by their Padé approximations (all-pass filters). But because this approximation is valid only at low frequencies, it is important to compare the true and approximate responses to choose the right approximation order and check the approximation validity. Use the pade command to compute Padé approximations of LTI models with delays. For example, consider a system with a PI controller:

Use this code to implement the system:
s = tf('s');
P = exp(-2.6*s)*(s+3)/(s^2+0.3*s+1);
C = 0.06 * (1 + 1/s);
T = feedback(ss(P*C),1);
For the PI controller, you can compare the exact closed-loop response T with the response obtained for a first-order Padé approximation of the delay:
T1 = pade(T,1);
step(T,'b--',T1,'r',100)
grid, legend('Exact','First-Order Pade')

The approximation error is large. To get a better approximation, try a second-order Padé approximation of the delay:
T2 = pade(T,2);
step(T,'b--',T2,'r',100)
grid, legend('Exact','Second-Order Pade')

The responses now match closely except for the nonminimum phase artifact ("wrong way" effect) introduced by the Padé approximation.
Delays are rarely known accurately, so it is often important to understand how sensitive a control system is to the delay value. Such sensitivity analysis is easily performed using LTI arrays and the InternalDelay property. For example, consider this notched PI control system developed in "PI Control Loop with Dead Time" from the Analyzing Control Systems with Delays demo.
% Create a 3rd-order plant with a PI controller and notch filter.
s = tf('s');
P = exp(-2.6*s)*(s+3)/(s^2+0.3*s+1);
C = 0.06 * (1 + 1/s);
T = feedback(ss(P*C),1)
notch = tf([1 0.2 1],[1 .8 1]);
C = 0.05 * (1 + 1/s);
Tnotch = feedback(ss(P*C*notch),1);Create five models with delay values ranging from 2.0 to 3.0:
tau = linspace(2,3,5); % 5 delay values
Tsens = repsys(Tnotch,[1 1 5]); % 5 copies of Tnotch
% for j=1:5
Tsens(:,:,j).InternalDelay = tau(j); % jth delay value
% -> jth model end
% Use step to create an envelope plot.
step(Tsens)
grid
title('Closed-loop response for 5 delay values between 2.0 and 3.0')

This plot shows that uncertainty on the delay value has little effect on closed-loop characteristics. Note that while you can change the values of internal delays, you cannot change how many there are because this is part of the model structure. To eliminate some internal delays, set their value to 0 or use pade with order zero:
Tnotch0 = Tnotch;
Tnotch0.InternalDelay = 0;
bode(Tnotch,'b',Tnotch0,'r',{1e-2,3})
grid, legend('Delay = 2.6','No delay','Location','SouthWest')

Discrete-time delays are handled in a similar way, but have some minor differences:
Discrete-time delays are always integer multiples of the sampling period.
Discrete-time delays are equivalent to poles at z=0, so it is always possible to absorb delays into the model dynamics (see delay2z). Keeping delays separate is better for performance, especially for systems with long delays compared to the sampling period.
For example, to specify the first-order model
![]()
with sampling period Ts=0.1, and a delay of 25 sample periods, use
H = tf(2,[1 -0.95],0.1,'inputdelay',25) step(H)

The equivalent state-space representation is:
H = ss(H)
a =
x1
x1 0.95
b =
u1
x1 2
c =
x1
y1 1
d =
u1
y1 0
Input delays (listed by channel): 25
Sampling time: 0.1
Discrete-time model.Next, consider the feedback loop below where g is a pure gain.

To compute the closed-loop response for g=0.01, type:
g = .01; T = feedback(g*H,1) step(T)

T is still a first-order model with an internal delay of 25 samples. For comparison, map all delays to poles at z=0 using delay2z:
T1 = delay2z(T);
order(T1)
ans =
26
The resulting model has 26 states and is therefore less efficient to simulate. As expected, however, the step responses of T and T1 match exactly:
step(T,'b',T1,'r--')
legend('T','T1')

In general, it is recommend to keep delays separate, except when analyzing the closed-loop dynamics of models with internal delays. For example:
rlocus(H)
axis([-1.25 1.25 -1.25 1.25])

You can use c2d to discretize continuous-time delay systems. Available methods include zero-order hold (ZOH), first-order hold (FOH), and Tustin. For models with internal delays, the ZOH discretization is not always exact, i.e., the continuous and discretized step responses may not match:
s = tf('s');
P = exp(-2.6*s)*(s+3)/(s^2+0.3*s+1);
C = 0.06 * (1 + 1/s);
T = feedback(ss(P*C),1);
Td = c2d(T,1); step(T,'b',Td,'r')
grid, legend('Continuous','ZOH Discretization')

To correct such discretization gaps, reduce the sampling period until the continuous and discrete responses match closely:
Td = c2d(T,0.05); step(T,'b',Td,'r')
grid, legend('Continuous','ZOH Discretization')
Warning: Discretization is only approximate due to internal delays.
Use faster sampling rate if discretization error is large.

Note that internal delays remain internal in the discretized model and do not inflate the model order:
order(Td)
ans =
3The following commands support internal delays for both continuous- and discrete-time systems:
All interconnection functions
Time domain response functions—except for impulse and initial
Frequency domain functions—except for norm
The following commands support internal delays for both continuous- and discrete-time systems and have certain limitations:
allmargin, margin—Uses interpolation, therefore these commands are only as precise as the fineness of the specified grid.
pole, zero—Returns poles and zeros of the system with all delays set to zero.
ssdata, get—If an SS model has internal delays, these commands return the A, B, C, and D matrices of the system with all internal delays set to zero. Augmented state-space equations keep track of which internal delays enter the model.
The following commands do not do not support time delays:
System dynamics—norm and lti/isstable
Time-domain analysis—initial, initialplot, impulse, and impulseplot
Model simplification—balreal, balred, minreal, modred, andsminreal
Conversions—to ZPK and TF representations
Compensator design—rlocus, lqg,lqry,lqrd, kalman,kalmd,lqgreg, lqgtrack, lqi, and augstate
In addition, the SISO Design Tool does not accept systems with internal delays.
State-space objects use generalized state-space equations to keep track of internal delays. Conceptually, such models consist of two interconnected parts:
An ordinary state-space model H(s) with an augmented I/O set
A bank of internal delays.

The corresponding state-space equations are:

You need not bother with this internal representation to use the tools. If, however, you want to extract H or the matrices A,B1,B2, ,... , you can use getDelayModel, For the example:
P = 5*exp(-3.4*s)/(s+1); C = 0.1 * (1 + 1/(5*s)); T = feedback(ss(P*C),1); [H,tau] = getDelayModel(T,'lft'); size(H)
Note that H is a two-input, two-output model whereas T is SISO. The inverse operation (combining H and tau to construct T) is performed by setDelayModel.
![]() | Model Conversion | Simulink Block for LTI Systems | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |