dss = DiscreteTransferFunction.Conversion.toStateSpacetoDiscreteStateSpace(dtf)
Transforms a discrete transfer function into discrete state space representation. There are an infinite number of possible realizations. Here, the transfer function is transformed into controller canonical form, i.e. the transfer function
b4*z^4 + b3*z^3 + b2*z^2 + b1*z + b0 y = -------------------------------------- *u a4*z^4 + a3*z^3 + a2*z^2 + a1*z + a0
is transformed into:
der(x) = A*x + B*u; y = C*x + D*u; with A = [ 0 , 1 , 0 , 0; 0 , 0 , 1 , 0: 0 , 0 , 0 , 1; -a0/a4, -a1/a4, -a2/a4, -a3/a4]; B = [ 0; 0; 0; 1/a4]; C = [b0-b4*a0/a4, b1-b4*a1/a4, b2-b4*a2/a4, b3-b4*a3/a4]; D = [b4/a4];
If the numerator polynomial is 1, then the state vector x is built up of the y(k) (the previous y) and of all the nx-1 predecessor (nx is the dimension of the state vector):
x(k+1) = {y(k-n+1), y(k-n+2), ..., y(k)};
Note, the state vector x of Modelica.Blocks.Continuous.TransferFunction is defined slightly differently.
TransferFunction z = Modelica_LinearSystems2.DiscreteTransferFunction.z(); Modelica_LinearSystems2.DiscreteTransferFunction dtf=(z+1)/(z^3 + z^2 + z +1); algorithm dss := Modelica_LinearSystems2.DiscreteTransferFunction.Conversion.toDiscreteStateSpace(dtf); // dss.A = [0, 1, 0; 0, 0, 1; -1, -1, -1], // dss.B = [0; 0; 1], // dss.C = [1, 1, 0], // dss.D = [0],
function toDiscreteStateSpace import Modelica; import Modelica_LinearSystems2; import Modelica_LinearSystems2.WorkInProgress.DiscreteTransferFunction; import Modelica_LinearSystems2.TransferFunction; import Modelica_LinearSystems2.WorkInProgress.DiscreteStateSpace; import Modelica.Math.Vectors; input DiscreteTransferFunction dtf "discrete transfer function of a system"; output DiscreteStateSpace dss(redeclare Real A[DiscreteTransferFunction.Analysis.denominatorDegree(dtf), DiscreteTransferFunction.Analysis.denominatorDegree(dtf)], redeclare Real B[DiscreteTransferFunction.Analysis.denominatorDegree(dtf), 1], redeclare Real B2[DiscreteTransferFunction.Analysis.denominatorDegree(dtf), 1], redeclare Real C[1, DiscreteTransferFunction.Analysis.denominatorDegree(dtf)], redeclare Real D[1, 1]) "Discrete state space record"; end toDiscreteStateSpace;