Skip to content

Commit 0ac2a7c

Browse files
committed
debug: SimResults doctest
1 parent d284c3e commit 0ac2a7c

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/estimator/execute.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Also store current inputs without operating points `u0` in `estim.lastu0`. This
77
used for [`PredictiveController`](@ref) computations.
88
"""
99
function remove_op!(estim::StateEstimator, u, ym, d)
10-
u0, d0 = estim.model.buffer.u, estim.model.buffer.d
10+
u0, d0 = estim.buffer.u, estim.buffer.d
1111
y0m = estim.buffer.ym
1212
u0 .= u .- estim.model.uop
1313
y0m .= @views ym .- estim.model.yop[estim.i_ym]

src/plot_sim.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ Simply call `plot` on them.
4141
4242
# Examples
4343
```jldoctest
44-
julia> model = LinModel(tf(1, [1, 1]), 1.0); N = 5; U_data = fill(1.0, 1, N);
44+
julia> model = LinModel(tf(1, [1, 1]), 1.0);
4545
46-
julia> Y_data = reduce(hcat, (updatestate!(model, U_data[:, i]); model()) for i=1:N)
46+
julia> N = 5; U_data = fill(1.0, 1, N); Y_data = zeros(1, N);
47+
48+
julia> for i=1:N; updatestate!(model, U_data[:, i]); Y_data[:, i] = model(); end; Y_data
4749
1×5 Matrix{Float64}:
4850
0.632121 0.864665 0.950213 0.981684 0.993262
4951

src/sim_model.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,9 @@ julia> x = updatestate!(model, [1])
234234
"""
235235
function updatestate!(model::SimModel{NT}, u, d=model.buffer.empty) where NT <: Real
236236
validate_args(model::SimModel, d, u)
237-
u0, d0 = model.buffer.u, model.buffer.d
237+
u0, d0, xnext0 = model.buffer.u, model.buffer.d, model.buffer.x
238238
u0 .= u .- model.uop
239239
d0 .= d .- model.dop
240-
xnext0 = model.buffer.x
241240
f!(xnext0, model, model.x0, u0, d0)
242241
xnext0 .+= model.fop .- model.xop
243242
model.x0 .= xnext0
@@ -264,9 +263,8 @@ julia> y = evaloutput(model)
264263
"""
265264
function evaloutput(model::SimModel{NT}, d=model.buffer.empty) where NT <: Real
266265
validate_args(model, d)
267-
d0 = model.buffer.d
266+
d0, y0 = model.buffer.d, model.buffer.y
268267
d0 .= d .- model.dop
269-
y0 = model.buffer.y
270268
h!(y0, model, model.x0, d0)
271269
y = y0
272270
y .+= model.yop

0 commit comments

Comments
 (0)