# Normalizing a transfer function

**URL:** https://discourse.julialang.org/t/normalizing-a-transfer-function/104834
**Category:** Modelling & Simulations
**Tags:** question, control, controlsystems
**Created:** [October 11, 2023, 8:04am UTC](https://discourse.julialang.org/t/normalizing-a-transfer-function/104834 "2023-10-11T08:04:51Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [October 11, 2023, 8:04am UTC](https://discourse.julialang.org/t/normalizing-a-transfer-function/104834/1 "2023-10-11T08:04:51Z")

</div>

Is there already a function to normalize a transfer function?  
I have:

```julia
TransferFunction{Continuous, ControlSystemsBase.SisoRational{Float64}}
                                 -951.729934283765s^2
---------------------------------------------------------------------------------------
3.1777394243568e7s^3 + 7.907227012152197e6s^2 + 540639.1480777722s + 5918.8473721761775

```

and I would like all coefficients to be divided by -951.729934283765.

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [October 11, 2023, 9:11am UTC](https://discourse.julialang.org/t/normalizing-a-transfer-function/104834/2 "2023-10-11T09:11:45Z")

</div>

OK, wrote a function that does this myself:

```julia
function normalize(tf_::TransferFunction{Continuous, ControlSystemsBase.SisoRational{Float64}})
    expr = tf_.matrix[1]
    factor = expr.num.coeffs[end]
    if factor == 0.0
        return tf_
    end
    tf(reverse(expr.num.coeffs./factor), reverse(expr.den.coeffs./factor))
end

```

---

<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: [October 11, 2023, 9:15am UTC](https://discourse.julialang.org/t/normalizing-a-transfer-function/104834/3 "2023-10-11T09:15:15Z")

</div>

You are reaching deep into the internals of ControlSystems here. See the functions `numvec` and `denvec` which would make your implementation simpler and avoid using internals.

> [@ufechner7](#):
>
> Is there already a function to normalize a transfer function?

No, because there are many possible ways one could possibly normalize a transfer function, and different people prefer different conventions.

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [October 11, 2023, 10:20am UTC](https://discourse.julialang.org/t/normalizing-a-transfer-function/104834/4 "2023-10-11T10:20:24Z")

</div>

Thank you!
