Return past value of operand
delay(u,tau)
delay(u,tau, History = u0, MaximumDelay = taumax)
Use the delay
operator in the equations
section
to refer to past values of expressions:
delay(u,tau)
= u(ttau)
The full syntax is:
delay(u,tau, History = u0, MaximumDelay = taumax)
The required operands are:
u
— The first operand is
the Simscape™ expression being delayed. It can be any numerical
expression that does not itself include delay
or der
operators.
tau
— The second operand
is the delay time. It must be a numerical expression with the unit
of time. The value of tau
can change, but it must
remain strictly positive throughout the simulation.
The optional operands may appear in any order. They are:
History
— The return value
for the initial time interval (t
<= StartTime
+ tau
).
The units of u
and u0
must be
commensurate. The default u0
is 0.
MaximumDelay
— The maximum
delay time. taumax
must be a constant or parametric
expression with the unit of time. If you specify MaximumDelay
= taumax
, a runtime error will be issued whenever tau
becomes
greater than taumax
.
Note
You have to specify 
At any time t
, delay(u,tau)
returns
a value approximating u
( t
 tau
)
for the current value of tau
. More specifically,
the expression delay(u,tau, History = u0)
is equivalent
to
if t <= (StartTime + tau) return u0(t) else return u(ttau) end
In other words, during the initial time interval, from the start
of simulation and until the specified delay time, tau
,
has elapsed, the delay
operator returns u0
(or
0, if History
is not specified). For simulation
times greater than tau
, the delay
operator
returns the past value of expression, u
( t
 tau
).
Note

This example shows implementation for a simple dynamic system:
$$\begin{array}{l}\dot{x}=x\left(t1\right)\\ x\left(t<0\right)=1\end{array}$$
The Simscape file looks as follows:
component MyDelaySystem parameters tau = {1.0,'s'}; end variables x = 1.0; end equations x.der == delay( x,tau,History = 1.0 )*{ 1, '1/s' }; % x' =  x(t  1) end end
MaximumDelay
is not required because tau
is
constant.
The { 1, '1/s' }
multiplication factor is
used to reconcile the units of expression and its time derivative.
See der
reference page for more
information.
For other examples of using the delay
operator,
see source for the PS Constant Delay and PS Variable Delay blocks
in the Simscape Foundation library (open the block dialog box
and click the View source link).
The Variable Transport
Delay example shows how you can model a variable transport
delay using the delay
operator. To see the implementation
details, open the example model, look under mask of the Transport
Delay subsystem, then rightclick the Variable Transport Delay block
and select View Simscape source.