Shift(t, steps) returns an operator shifting a discrete time variable by
steps ticks: Shift(t, -1)(x) is the previous value of x. The
operator distributes over expressions and merges with other shifts. Only
non-positive shifts are allowed in models.
Usage
Shift(t, steps = 1L)
ShiftIndex(clock = NULL, steps = 0L)
Sample(clock = NULL)
Hold(x)
SampleTime(clock = NULL)
hasshift(e)
hassample(e)
hashold(e)Arguments
- t
The independent variable.
- steps
Number of ticks.
- clock
A
Clock(), a sample interval, the independent variable (for integer steps) orNULLto infer it.- x
A variable or expression.
- e
An expression or equation.
Details
k <- ShiftIndex(clock) indexes variables on a clock: k(x) is x at
the current tick and (k - 1)(x) (or k(x, -1)) its value one tick
earlier. ShiftIndex(t) counts integer steps of a purely discrete
system, ShiftIndex(dt) uses Clock(dt), and ShiftIndex() infers the
clock.
Sample(dt)(x) (or Sample(clock)(x)) samples a continuous variable at
the ticks of a clock, Sample(x) with an inferred clock. Hold(xd) holds
a discrete variable constant between ticks (zero order hold), making it
available to continuous equations. SampleTime() is the sample interval
of the clock inferred for its equation.
hasshift(), hassample() and hashold() test for the operators.