# .Modelica_LinearSystems2.DiscreteZerosAndPoles.Conversion.toDiscreteStateSpace

## Information

#### Syntax

```dss = DiscreteZerosAndPoles.ConversiontoDiscreteStateSpace(dzp)
```

#### Description

This function transforms a discrete zeros-poles-gain system representation into the corresponding discrete state space representation. To achieve well numerical condition the DiscreteZerosAndPoles transfer function is transformed into discrete state space form by creating first and second order blocks that are connected together in series. Every block is represented in controller canonical form and scaled such that the gain from the input of this block to its output is one (i.e. y(p=0) = u(p=0)), if this is possible.

The construction of the state space blocks is the same as of the corresponding continuous transformation ( ZerosAndPoles.Conversion.toStateSpace()), except for that the first order and second order systems are scaled by

```       1 + n1
k_2 = --------
1 + d1
```

and

```       1 + n2 + n2
k_2 = -------------
1 + d2 + d2
```

respectiively.

#### Example

```  DiscreteZerosAndPoles q = Modelica_LinearSystems2.DiscreteZerosAndPoles.q();
Modelica_LinearSystems2.DiscreteZerosAndPoles dzp=(q+1)/(q^2 + q + 1);

algorithm
dss := Modelica_LinearSystems2.DiscreteZerosAndPoles.Conversion.toDiscreteStateSpace(dzp);
// dss.A = [0, 1; -1, -1],
// dss.B = [0; 3],
// dss.C = [0.333, 0.333],
// dss.D = [0],
// dss.B2 = [0; 0],
```

#### Interface

```function toDiscreteStateSpace
import Modelica;
import Modelica_LinearSystems2;
import Modelica_LinearSystems2.ZerosAndPoles;
import Modelica_LinearSystems2.Math.Vectors;
import Modelica_LinearSystems2.Math.Complex;
import Modelica_LinearSystems2.DiscreteStateSpace;
import Modelica_LinearSystems2.DiscreteZerosAndPoles;
input DiscreteZerosAndPoles dzp "ZerosAndPoles transfer function of a system";
output DiscreteStateSpace dss(redeclare Real A[DiscreteZerosAndPoles.Analysis.denominatorDegree(dzp), DiscreteZerosAndPoles.Analysis.denominatorDegree(dzp)], redeclare Real B[DiscreteZerosAndPoles.Analysis.denominatorDegree(dzp), 1], redeclare Real C[1, DiscreteZerosAndPoles.Analysis.denominatorDegree(dzp)], redeclare Real D[1, 1]) "Transfer function in StateSpace SISO form";
end toDiscreteStateSpace;
```

Generated at 2020-06-02T01:38:30Z by OpenModelicaOpenModelica 1.16.0~dev-420-gc007a39 using GenerateDoc.mos