# Building rational transfer functions

Construction of rational transfer function object.`RationalTransferFunction`

Building rational transfer functions.`rtf`

`DescriptorSystems.RationalTransferFunction`

— Type`r = RationalTransferFunction(num::AbstractPolynomial, den::AbstractPolynomial, Ts:Real)`

Construct a rational transfer function model `r`

from its numerator and denominator polynomials `num`

and `den`

, respectively, and sampling time `Ts`

.

If `r::RationalTransferFunction{T,λ,P <: Polynomial(T,λ),Ts}`

is a rational transfer function system model object defined as `r(λ) = num(λ)/den(λ)`

, where `num(λ)`

and `den(λ)`

are polynomials with coefficients in `T`

and with the indeterminate `λ`

, and `Ts`

is the sampling time, then:

`r.num`

is the numerator polynomial `num(λ)`

;

`r.den`

is the denominator polynomial `den(λ)`

.

The sampling time `Ts`

can have the following values:

`Ts = 0`

for a continuous-time system and`λ = s`

is the complex variable in the Laplace transform;`Ts > 0`

or`Ts = -1`

for a discrete-time system and`λ = z`

is the complex variable in the`Z`

-transform;`Ts = -1`

indicates a discrete-time system with an unspecified sampling time.

The sampling time can be obtained as `r.Ts`

. The symbol (or *variable*) used for the indeterminate `λ`

is the common symbol used for the indeterminates of the polynomials `num(λ)`

and `den(λ)`

and can be obtained as `r.var`

. The roots of the numerator polynomial `num(λ)`

(also called *zeros* of `r(λ)`

) can be obtained as `r.zeros`

, while the roots of the denominator polynomial `den(λ)`

(also called *poles* of `r(λ)`

) can be obtained as `r.poles`

. The ratio of the leading polynomial coefficients of `num(λ)`

and `den(λ)`

(also called *gain* of `r(λ)`

) can be obtained as `r.gain`

.

`DescriptorSystems.rtf`

— Function`r = rtf(num, den; Ts = rts, var = rvar )`

Create the rational transfer function `r(λ) = num(λ)/den(λ)`

with the polynomials `num(λ)`

and `den(λ)`

, sampling time `rts`

and variable name `rvar`

, representing the transfer function of a single-input single-output system of the form

`Y(λ) = r(λ) U(λ),`

where `U(λ)`

and `Y(λ)`

are the Laplace or `Z`

transformed input `u(t)`

and output `y(t)`

, respectively, and `λ = s`

, the complex variable in the Laplace transform, if `rts = 0`

, or `λ = z`

, the complex variable in the `Z`

transform, if `rts ≠ 0`

. Both `num`

and `den`

can be real or complex numbers as well.

The resulting `r`

is such that `r.Ts = rts`

(default `rts = 0`

) and `r.var = rvar`

. The default value of `rvar`

is `rvar = Polynomials.indeterminate(num)`

if `num`

is a polynomial, `rvar = Polynomials.indeterminate(den)`

if `num`

is a number and `den`

is a polynomial, and `rvar = :s`

if both `num`

and `den`

are numbers.

`r = rtf(f; Ts = rts, var = rvar)`

Create the rational transfer function `r(λ) = f(λ)`

with sampling time `rts`

and variable name `rvar`

such that:

(1) if `f(λ)`

is a rational transfer function, then `r.Ts = rts`

(default `rts = f.Ts`

) and `r.var = rvar`

(default `rvar = f.var`

);

(2) if `f(λ)`

is a rational function, then `r.Ts = rts`

(default `rts = 0`

) and `r.var = rvar`

(default `rvar = Polynomials.indeterminate(f.num)`

);

(3) if `f(λ)`

is a polynomial, then `r.Ts = rts`

(default `rts = 0`

) and `r.var = rvar`

(default `rvar = Polynomials.indeterminate(f)`

);

(4) if `f(λ)`

is a ral or complex number, then `r.Ts = rts`

(default `rts = 0`

) and `r.var = rvar`

(default `rvar = :s`

);

```
r = rtf(var; Ts = rts)
r = rtf('s') or r = rtf('z'; Ts = rts)
r = rtf("s") or r = rtf("z"; Ts = rts)
r = rtf(:s) or r = rtf(:z; Ts = rts)
```

Create the rational transfer function `r(λ) = λ`

, such that `r.var`

and `r.Ts`

are set as follows:

```
(1) `r.var = :s` and `r.Ts = 0` if `var = 's'`, or `var = "s"` or `var = :s` ;
(2) `r.var = :z` and `r.Ts = rts` if `var = 'z'`, or `var = "z"` or `var = :z`;
(3) `r.var = var` and `r.Ts = rts` (default `rts = 0.`) otherwise.
```

`r = rtf(z, p, k; Ts = rts, var = rvar)`

Create from the roots (zeros) `z`

, poles `p`

, gain `k`

, sampling time `rts`

and variable name `rvar`

the rational transfer function `r(λ) = k*num(λ)/den(λ)`

, where `num(λ)`

and `den(λ)`

are monic polynomials with roots equal `z`

and `p`

, respectively, and such that `r.Ts = rts`

(default `rts = 0`

) and `r.var = rvar`

(default `rvar = :s`

if `Ts = 0`

or `rvar = :z`

if `Ts ≠ 0`

).