Skip to content

Commit 63aea64

Browse files
Merge pull request #2560 from SciML/baggepinnen-patch-4
Add missing updates to sampled-data docs
2 parents a29b41e + e5efd40 commit 63aea64

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

docs/src/tutorials/SampledData.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ k = ShiftIndex(clock)
3939
4040
eqs = [
4141
x(k) ~ 0.5x(k - 1) + u(k - 1),
42-
y(k) ~ x(k - 1)
42+
y ~ x
4343
]
4444
```
4545

@@ -49,13 +49,13 @@ A few things to note in this basic example:
4949
- `x` and `u` are automatically inferred to be discrete-time variables, since they appear in an equation with a discrete-time [`ShiftIndex`](@ref) `k`.
5050
- `y` is also automatically inferred to be a discrete-time-time variable, since it appears in an equation with another discrete-time variable `x`. `x,u,y` all belong to the same discrete-time partition, i.e., they are all updated at the same *instantaneous point in time* at which the clock ticks.
5151
- The equation `y ~ x` does not use any shift index, this is equivalent to `y(k) ~ x(k)`, i.e., discrete-time variables without shift index are assumed to refer to the variable at the current time step.
52-
- The equation `x(k) ~ 0.5x(k-1) + u(k-1)` indicates how `x` is updated, i.e., what the value of `x` will be at the *current* time step in terms of the *past* value. The output `y`, is given by the value of `x` at the *past* time step, i.e., `y(k) ~ x(k-1)`. If this logic was implemented in an imperative programming style, the logic would thus be
52+
- The equation `x(k) ~ 0.5x(k-1) + u(k-1)` indicates how `x` is updated, i.e., what the value of `x` will be at the *current* time step in terms of the *past* value. The output `y`, is given by the value of `x` at the *current* time step, i.e., `y(k) ~ x(k)`. If this logic was implemented in an imperative programming style, the logic would thus be
5353

5454
```julia
5555
function discrete_step(x, u)
56-
y = x # y is assigned the current value of x, y(k) = x(k-1)
5756
x = 0.5x + u # x is updated to a new value, i.e., x(k) is computed
58-
return x, y # The state x now refers to x at the current time step, x(k), while y refers to x at the past time step, y(k) = x(k-1)
57+
y = x # y is assigned the current value of x, y(k) = x(k)
58+
return x, y # The state x now refers to x at the current time step, x(k), and y equals x, y(k) = x(k)
5959
end
6060
```
6161

@@ -68,22 +68,21 @@ eqs = [
6868
]
6969
```
7070

71-
but the use of positive time shifts is not yet supported.
72-
Instead, we have *shifted all indices* by `-1`, resulting in exactly the same difference equations. However, the next system is *not equivalent* to the previous one:
71+
but the use of positive time shifts is not yet supported. Instead, we *shifted all indices* by `-1` above, resulting in exactly the same difference equations. However, the next system is *not equivalent* to the previous one:
7372

7473
```@example clocks
7574
eqs = [
76-
x(k) ~ 0.5x(k - 1) + u(k - 1),
75+
x(k) ~ 0.5x(k - 1) + u(k),
7776
y ~ x
7877
]
7978
```
8079

81-
In this last example, `y` refers to the updated `x(k)`, i.e., this system is equivalent to
80+
In this last example, `u(k)` refers to the input at the new time point `k`., this system is equivalent to
8281

8382
```
8483
eqs = [
85-
x(k+1) ~ 0.5x(k) + u(k),
86-
y(k+1) ~ x(k+1)
84+
x(k+1) ~ 0.5x(k) + u(k+1),
85+
y(k) ~ x(k)
8786
]
8887
```
8988

0 commit comments

Comments
 (0)