# Are there rational transfer functions available in Julia?

**URL:** <https://discourse.julialang.org/t/are-there-rational-transfer-functions-available-in-julia/55638>\
**Category:** General Usage\
**Tags:** dsp\
**Created:** [February 19, 2021, 6:13pm UTC](https://discourse.julialang.org/t/are-there-rational-transfer-functions-available-in-julia/55638 "2021-02-19T18:13:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![askvorts](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/askvorts/32/7120_2.png) [@askvorts](https://discourse.julialang.org/u/askvorts)\
**Post date:** [February 19, 2021, 6:13pm UTC](https://discourse.julialang.org/t/are-there-rational-transfer-functions-available-in-julia/55638/1 "2021-02-19T18:13:25Z")

</div>

Are there available rational transfer functions, possibly equivalent to MATLAB’s functions `filter(b,1,x)` and `filter(b,a,x,zi)` where `zi` are initial conditions for filter delays. Thanks in advance!

---

<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 19, 2021, 6:44pm UTC](https://discourse.julialang.org/t/are-there-rational-transfer-functions-available-in-julia/55638/2 "2021-02-19T18:44:31Z")

</div>

I haven’t used `filter` in MATLAB, but isn’t this simply defining a system:

y = \frac{b\_0 + b\_1 z^{-1} + \ldots + b\_{n\_b} z^{-n\_b}}{1+a\_1 z^{-1}+\ldots+a\_{n\_a}z^{-n\_a}}z^{-n\_d} \cdot u

where n\_a \ge n\_b (assuming a proper system) and n\_d a possible delay? And then using `x` as input (u) and computing the resulting output y?

If so, this can be handled with relative ease by defining a transfer function using the ControlSystems.jl package and simulating the resulting dynamic system with `x` as input.

The ControlSystems.jl package has built-in set-ups for the case that `x` (or: u) is a step input or an impulse input.

But there is also a function `lsim` for simulating the system with a specified input.

Note: I haven’t tested ControlSystems.jl for this particular case, though.

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [February 19, 2021, 8:42pm UTC](https://discourse.julialang.org/t/are-there-rational-transfer-functions-available-in-julia/55638/3 "2021-02-19T20:42:33Z")

</div>

DSP.jl has your requested filter methods. Controlsystems.jl does have a more general support for transfer functions as they are commonly used in control, but for filtering, DSP.jl is what you want.

---

<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 19, 2021, 9:14pm UTC](https://discourse.julialang.org/t/are-there-rational-transfer-functions-available-in-julia/55638/4 "2021-02-19T21:14:33Z")

</div>

Ah. `DSP.filt(b,a,x,[si])`, etc. seems to be what is asked for.

---

<div class="post-metadata">

**Author:** ![askvorts](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/askvorts/32/7120_2.png) [@askvorts](https://discourse.julialang.org/u/askvorts)\
**Post date:** [February 20, 2021, 12:07am UTC](https://discourse.julialang.org/t/are-there-rational-transfer-functions-available-in-julia/55638/5 "2021-02-20T00:07:43Z")

</div>

Thank you very much to both!
