Skip to content

Commit 2e481ec

Browse files
committed
doc: mtk example now uses the in-place output function
(but still crash with same error `BoundsError: attempt to access Float64 at index [2]`)
1 parent 2cb763f commit 2e481ec

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

docs/src/manual/mtk.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,18 @@ function generate_f_h(model, inputs, outputs)
7676
end
7777
return nothing
7878
end
79-
h_ = ModelingToolkit.build_explicit_observed_function(io_sys, outputs; inputs)
79+
return_inplace = true
80+
(_, h_ip) = ModelingToolkit.build_explicit_observed_function(
81+
io_sys, outputs; inputs, return_inplace
82+
)
83+
println(h_ip)
8084
u_nothing = fill(nothing, nu)
8185
function h!(y, x, _ , p)
82-
y .= try
86+
try
8387
# MTK.jl supports a `u` argument in `h_` function but not this package. We set
8488
# `u` as a vector of nothing and `h_` function will presumably throw an
8589
# MethodError it this argument is used inside the function
86-
h_(x, u_nothing, p, nothing)
90+
h_ip(y, x, u_nothing, p, nothing)
8791
catch err
8892
if err isa MethodError
8993
error("NonLinModel only support strictly proper systems (no manipulated "*

0 commit comments

Comments
 (0)