dss = 'constructor'.fromStateSpace(ss, Ts) dss = 'constructor'.fromStateSpace(ss, Ts, method)
This function derives a linear time invariant difference equation system in state space form
x(Ts*(k+1)) = A * x(Ts*k) + B * u(Ts*k) y(Ts*k) = C * x(Ts*k) + D * u(Ts*k) x_continuous(Ts*k) = x(Ts*k) + B2 * u(Ts*k)
with
from continuous state space form
der(xc(t)) = ss.A * xc(t) + ss.B * us(t) yc(t) = ss.C * xc(t) + ss.D * uc(t)
The applied discretization method is selected by the user from
import dss=Modelica_LinearSystems2.DiscreteStateSpace; import Modelica_LinearSystems2.StateSpace; StateSpace ss=StateSpace(A = [1], B = [1], C = [1], D = [0]); Modelica.Units.SI.Time Ts=0.1; Modelica_LinearSystems2.Types.Method method=Modelica_LinearSystems2.Types.Method.Trapezoidal; public DiscreteStateSpace dss; algorithm dss := dss.'constructor'.fromStateSpace(ss, Ts); //or just: //dss := dss(ss=ss, Ts=Ts, method=method); // dss.A = [1.1053], // dss.B = [0.11080], // dss.C = [1], // dss.D = [0.0526], // dss.Ts = 0.1, // dss.B2 = [0.0526], // dss.method = Modelica_LinearSystems2.Types.Method.Trapezoidal
function fromStateSpace import Modelica; import MatricesMSL = Modelica.Math.Matrices; import Modelica_LinearSystems2; import Modelica_LinearSystems2.Utilities.Types.Method; input Modelica_LinearSystems2.StateSpace ss "Continuous linear state space system"; input Modelica.Units.SI.Time Ts "Sample time"; input Method method = Method.Trapezoidal "Discretization method"; output Modelica_LinearSystems2.DiscreteStateSpace dss(redeclare Real A[size(ss.A, 1), size(ss.A, 2)], redeclare Real B[size(ss.B, 1), size(ss.B, 2)], redeclare Real C[size(ss.C, 1), size(ss.C, 2)], redeclare Real D[size(ss.D, 1), size(ss.D, 2)], redeclare Real B2[size(ss.B, 1), size(ss.B, 2)]) "Discrete state space system"; end fromStateSpace;