@@ -22,7 +22,7 @@ Manually construct a `SimResult` to quickly plot `obj` simulations.
22
22
23
23
Except for `obj`, all the arguments should be matrices of `N` columns, where `N` is the
24
24
number of time steps. [`SimResult`](@ref) objects allow to quickly plot simulation results.
25
- Simply call `plot` from [`Plots.jl`](https://github.com/JuliaPlots/Plots.jl) on them.
25
+ Simply call `plot` on them.
26
26
27
27
# Arguments
28
28
!!! info
@@ -39,7 +39,7 @@ Simply call `plot` from [`Plots.jl`](https://github.com/JuliaPlots/Plots.jl) on
39
39
- `Ru_data` : manipulated input setpoints
40
40
41
41
# Examples
42
- ```julia-repl
42
+ ```jldoctest
43
43
julia> plant = LinModel(tf(1, [1, 1]), 1.0); N = 5; U_data = fill(1.0, 1, N);
44
44
45
45
julia> Y_data = reduce(hcat, (updatestate!(plant, U_data[:, i]); plant()) for i=1:N)
@@ -48,9 +48,6 @@ julia> Y_data = reduce(hcat, (updatestate!(plant, U_data[:, i]); plant()) for i=
48
48
49
49
julia> res = SimResult(plant, U_data, Y_data)
50
50
Simulation results of LinModel with 5 time steps.
51
-
52
- julia> using Plots; plot(res)
53
-
54
51
```
55
52
"""
56
53
function SimResult (
@@ -108,18 +105,15 @@ Open-loop simulation of `plant` for `N` time steps, default to unit bump test on
108
105
The manipulated inputs ``\m athbf{u}`` and measured disturbances ``\m athbf{d}`` are held
109
106
constant at `u` and `d` values, respectively. The plant initial state ``\m athbf{x}(0)`` is
110
107
specified by `x_0` keyword arguments. The function returns [`SimResult`](@ref) instances
111
- that can be visualized by calling `plot` from [`Plots.jl`](https://github.com/JuliaPlots/Plots.jl)
112
- on them (see Examples below). Note that the method mutates `plant` internal states.
108
+ that can be visualized by calling `plot` on them. Note that the method mutates `plant`
109
+ internal states.
113
110
114
111
# Examples
115
- ```julia-repl
112
+ ```jldoctest
116
113
julia> plant = NonLinModel((x,u,d)->0.1x+u+d, (x,_)->2x, 10.0, 1, 1, 1, 1, solver=nothing);
117
114
118
115
julia> res = sim!(plant, 15, [0], [0], x_0=[1])
119
116
Simulation results of NonLinModel with 15 time steps.
120
-
121
- julia> using Plots; plot(res, plotu=false, plotd=false, plotx=true)
122
-
123
117
```
124
118
"""
125
119
function sim! (
@@ -184,16 +178,13 @@ vectors. The simulated sensor and process noises of `plant` are specified by `y_
184
178
- `lastu = plant.uop` : last plant input ``\m athbf{u}`` for ``\m athbf{x̂}`` initialization
185
179
186
180
# Examples
187
- ```julia-repl
181
+ ```jldoctest
188
182
julia> model = LinModel(tf(3, [30, 1]), 0.5);
189
183
190
184
julia> estim = KalmanFilter(model, σR=[0.5], σQ=[0.25], σQint_ym=[0.01], σPint_ym_0=[0.1]);
191
185
192
186
julia> res = sim!(estim, 50, [0], y_noise=[0.5], x_noise=[0.25], x_0=[-10], x̂_0=[0, 0])
193
187
Simulation results of KalmanFilter with 50 time steps.
194
-
195
- julia> using Plots; plot(res, plotŷ=true, plotu=false, plotxwithx̂=true)
196
-
197
188
```
198
189
"""
199
190
function sim! (
@@ -222,16 +213,13 @@ The output and manipulated input setpoints are held constant at `ry` and `ru`, r
222
213
The keyword arguments are identical to [`sim!(::StateEstimator, ::Int)`](@ref).
223
214
224
215
# Examples
225
- ```julia-repl
216
+ ```jldoctest
226
217
julia> model = LinModel([tf(3, [30, 1]); tf(2, [5, 1])], 4);
227
218
228
219
julia> mpc = setconstraint!(LinMPC(model, Mwt=[0, 1], Nwt=[0.01], Hp=30), ymin=[0, -Inf]);
229
220
230
221
julia> res = sim!(mpc, 25, [0, 0], y_noise=[0.1], y_step=[-10, 0])
231
222
Simulation results of LinMPC with 25 time steps.
232
-
233
- julia> using Plots; plot(res, plotry=true, plotŷ=true, plotymin=true, plotu=true)
234
-
235
223
```
236
224
"""
237
225
function sim! (
0 commit comments