@@ -22,7 +22,7 @@ Manually construct a `SimResult` to quickly plot `obj` simulations.
2222
2323Except for `obj`, all the arguments should be matrices of `N` columns, where `N` is the
2424number 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.
2626
2727# Arguments
2828!!! info
@@ -39,7 +39,7 @@ Simply call `plot` from [`Plots.jl`](https://github.com/JuliaPlots/Plots.jl) on
3939- `Ru_data` : manipulated input setpoints
4040
4141# Examples
42- ```julia-repl
42+ ```jldoctest
4343julia> plant = LinModel(tf(1, [1, 1]), 1.0); N = 5; U_data = fill(1.0, 1, N);
4444
4545julia> 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=
4848
4949julia> res = SimResult(plant, U_data, Y_data)
5050Simulation results of LinModel with 5 time steps.
51-
52- julia> using Plots; plot(res)
53-
5451```
5552"""
5653function SimResult (
@@ -108,18 +105,15 @@ Open-loop simulation of `plant` for `N` time steps, default to unit bump test on
108105The manipulated inputs ``\m athbf{u}`` and measured disturbances ``\m athbf{d}`` are held
109106constant at `u` and `d` values, respectively. The plant initial state ``\m athbf{x}(0)`` is
110107specified 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.
113110
114111# Examples
115- ```julia-repl
112+ ```jldoctest
116113julia> plant = NonLinModel((x,u,d)->0.1x+u+d, (x,_)->2x, 10.0, 1, 1, 1, 1, solver=nothing);
117114
118115julia> res = sim!(plant, 15, [0], [0], x_0=[1])
119116Simulation results of NonLinModel with 15 time steps.
120-
121- julia> using Plots; plot(res, plotu=false, plotd=false, plotx=true)
122-
123117```
124118"""
125119function sim! (
@@ -184,16 +178,13 @@ vectors. The simulated sensor and process noises of `plant` are specified by `y_
184178- `lastu = plant.uop` : last plant input ``\m athbf{u}`` for ``\m athbf{x̂}`` initialization
185179
186180# Examples
187- ```julia-repl
181+ ```jldoctest
188182julia> model = LinModel(tf(3, [30, 1]), 0.5);
189183
190184julia> estim = KalmanFilter(model, σR=[0.5], σQ=[0.25], σQint_ym=[0.01], σPint_ym_0=[0.1]);
191185
192186julia> res = sim!(estim, 50, [0], y_noise=[0.5], x_noise=[0.25], x_0=[-10], x̂_0=[0, 0])
193187Simulation results of KalmanFilter with 50 time steps.
194-
195- julia> using Plots; plot(res, plotŷ=true, plotu=false, plotxwithx̂=true)
196-
197188```
198189"""
199190function sim! (
@@ -222,16 +213,13 @@ The output and manipulated input setpoints are held constant at `ry` and `ru`, r
222213The keyword arguments are identical to [`sim!(::StateEstimator, ::Int)`](@ref).
223214
224215# Examples
225- ```julia-repl
216+ ```jldoctest
226217julia> model = LinModel([tf(3, [30, 1]); tf(2, [5, 1])], 4);
227218
228219julia> mpc = setconstraint!(LinMPC(model, Mwt=[0, 1], Nwt=[0.01], Hp=30), ymin=[0, -Inf]);
229220
230221julia> res = sim!(mpc, 25, [0, 0], y_noise=[0.1], y_step=[-10, 0])
231222Simulation results of LinMPC with 25 time steps.
232-
233- julia> using Plots; plot(res, plotry=true, plotŷ=true, plotymin=true, plotu=true)
234-
235223```
236224"""
237225function sim! (
0 commit comments