Skip to content

Commit b7929f1

Browse files
committed
debug example sim! in doc
1 parent 9ddf8b3 commit b7929f1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/plot_sim.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ julia> res = SimResult(plant, U_data, Y_data)
4242
Simulation results of LinModel with 5 time steps.
4343
4444
julia> using Plots; plot(res)
45+
4546
```
4647
"""
4748
function SimResult(
@@ -83,7 +84,7 @@ get_nx̂(mpc::PredictiveController) = mpc.estim.nx̂
8384

8485
function Base.show(io::IO, res::SimResult)
8586
N = length(res.T_data)
86-
print(io, "Simulation results of $(typeof(res.obj)) with $N time steps.")
87+
print(io, "Simulation results of $(typeof(res.obj).name.name) with $N time steps.")
8788
end
8889

8990

@@ -102,7 +103,8 @@ on them (see Examples below). Note that the method mutates `plant` internal stat
102103
```julia-repl
103104
julia> plant = NonLinModel((x,u,d)->0.1x+u+d, (x,_)->2x, 10.0, 1, 1, 1, 1);
104105
105-
julia> res = sim!(plant, 15, [0], [0], x0=[1]);
106+
julia> res = sim!(plant, 15, [0], [0], x0=[1])
107+
Simulation results of NonLinModel with 15 time steps.
106108
107109
julia> using Plots; plot(res, plotu=false, plotd=false, plotx=true)
108110
@@ -169,9 +171,10 @@ vectors. The simulated sensor and process noises of `plant` are specified by `y_
169171
```julia-repl
170172
julia> model = LinModel(tf(3, [30, 1]), 0.5);
171173
172-
julia> estim = KalmanFilter(model, σR=[0.5], σQ=[0.25], σQ_int=[0.01], σP0_int=[0.1]);
174+
julia> estim = KalmanFilter(model, σR=[0.5], σQ=[0.25], σQint_ym=[0.01], σP0int_ym=[0.1]);
173175
174-
julia> res = sim!(estim, 50, [0], y_noise=[0.5], x_noise=[0.25], x0=[-10], x̂0=[0, 0]);
176+
julia> res = sim!(estim, 50, [0], y_noise=[0.5], x_noise=[0.25], x0=[-10], x̂0=[0, 0])
177+
Simulation results of KalmanFilter with 50 time steps.
175178
176179
julia> using Plots; plot(res, plotŷ=true, plotu=false, plotxwithx̂=true)
177180
@@ -208,7 +211,8 @@ julia> model = LinModel([tf(3, [30, 1]); tf(2, [5, 1])], 4);
208211
209212
julia> mpc = setconstraint!(LinMPC(model, Mwt=[0, 1], Nwt=[0.01], Hp=30), ymin=[0, -Inf]);
210213
211-
julia> res = sim!(mpc, 25, [0, 0], y_noise=[0.1], y_step=[-10, 0]);
214+
julia> res = sim!(mpc, 25, [0, 0], y_noise=[0.1], y_step=[-10, 0])
215+
Simulation results of LinMPC with 25 time steps.
212216
213217
julia> using Plots; plot(res, plotry=true, plotŷ=true, plotymin=true, plotu=true)
214218

0 commit comments

Comments
 (0)