# Interpolation within ModelingToolkit framework

**URL:** https://discourse.julialang.org/t/interpolation-within-modelingtoolkit-framework/59432
**Category:** New to Julia
**Tags:** modelingtoolkit
**Created:** [April 16, 2021, 6:35pm UTC](https://discourse.julialang.org/t/interpolation-within-modelingtoolkit-framework/59432 "2021-04-16T18:35:06Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![jairorua](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jairorua/32/24109_2.png) [@jairorua](https://discourse.julialang.org/u/jairorua)
#### Post date: [April 22, 2021, 8:07pm UTC](https://discourse.julialang.org/t/interpolation-within-modelingtoolkit-framework/59432/6 "2021-04-22T20:07:56Z")

</div>

Many thanks for your help @ChrisRackauckas. The work of the MKT team in this package is fantastic.

Just some constructive feedback. I feel that the `@register` functionality might be useful to many people. However, a quick search of `@register` in the search docs bar only leads to Composing Ordinary Differential Equations - Specifying a time-variable forcing function, where it says:

" MTK allows to “register” arbitrary Julia functions, which are excluded from symbolic transformations but are just used as-is. So, you could, for example, interpolate a given time series using [DataInterpolations.jl](https://github.com/PumasAI/DataInterpolations.jl)."

From this description, at least for a new user of MTK like me, it is a bit difficult to infer that I can specify some variables as non-symbolic and the remaining as symbolic. I took the liberty of using the example included in the documentation and include a function that interpolates some time-series data with a mix of non-symbolic and symbolic inputs. Here is the code:

```julia
using ModelingToolkit
using DifferentialEquations
using DataInterpolations 

@parameters tau
@variables t, x(t), f(t)
D = Differential(t)

function f_interpolate(t, table_t, table_u)

	interpolator = QuadraticInterpolation(table_u, table_t)
	output = interpolator(t)

end

@register f_interpolate(t, table_t::AbstractVector, table_u::AbstractVector)

table_t, table_u = LinRange(0.5, 10.5, 10), randn(10)

@named fol_external_f = ODESystem([f ~ f_interpolate(t, table_t, table_u), D(x) ~ (f - x) / tau])
prob = ODEProblem(structural_simplify(fol_external_f), [x => 0.0], (0.0, 10.0), [tau => 0.75])

sol = solve(prob)
plot(sol, vars=[x, f])
scatter!(table_t, table_u)

```

![Capture3](https://global.discourse-cdn.com/julialang/original/3X/4/7/47f1eb12dada2572274456c3a3e7d7d1af401a03.png)

If you feel this may complement the existing documentation, feel free to add it. Otherwise it is left here so it may help future new users.

---

_[View the full topic](https://discourse.julialang.org/t/interpolation-within-modelingtoolkit-framework/59432)._
