# MTK: interpolation of observed variables?

**URL:** <https://discourse.julialang.org/t/mtk-interpolation-of-observed-variables/94193>\
**Category:** Modelling & Simulations\
**Created:** [February 7, 2023, 10:53am UTC](https://discourse.julialang.org/t/mtk-interpolation-of-observed-variables/94193 "2023-02-07T10:53:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)\
**Post date:** [February 7, 2023, 10:53am UTC](https://discourse.julialang.org/t/mtk-interpolation-of-observed-variables/94193/1 "2023-02-07T10:53:00Z")

</div>

Suppose I do a simulation of a model using ModelingToolkit.jl, where `x` is the state, `y` is an observed variable, and the solution object is `sol`. Then

```julia
sol[x]
sol[y]

```

give vectors of the solution of `x` and `y` at the time points given by `sol.t` (or: `sol[t]`).

Suppose I instead want an interpolation value?

```julia
sol(0.5)

```

gives the interpolated value of `x` at time `t=0.5`.

- How can I get an interpolated value of `y`?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [February 7, 2023, 11:01am UTC](https://discourse.julialang.org/t/mtk-interpolation-of-observed-variables/94193/2 "2023-02-07T11:01:55Z")

</div>

`sol(0.5; idxs = y)`
