dss = 'constructor'.fromMatrices(A, B, C, D) dss = 'constructor'.fromMatrices(A, B, C, D, Ts, B2, method)
This function constructs a DiscreteStateSpace record dss with
dss.A = A; dss.B = B; dss.C = C; dss.D = D; dss.B2 = B2; dss.Ts = Ts; dss.method = method;
i.e. the input-matrices are the system matrices of the discrete system. The default values of sample time Ts and discretization method method are
Ts = 1 method = Modelica_LinearSystems2.Types.Method.Trapezoidal
respectively. See also fromMatrices2 where the inputs are the matrices of a continuous system which is to convert to discrete state space.
import dss=Modelica_LinearSystems2.DiscreteStateSpace; Real A[1,1] = [1]; Real B[1,1] = [1]; Real C[1,1] = [1]; Real D[1,1] = [0]; public DiscreteStateSpace dss; algorithm dss := dss.'constructor'.fromMatrices(A, B, C, D) // or just: dss := dss(A, B, C, D, Ts=1, B2=[0], method=Modelica_LinearSystems2.Types.Method.Trapezoidal); // dss.A = [1] // dss.B = [1] // dss.C = [1] // dss.D = [0] // dss.B2 = [0] // dss.Ts = 1 // dss.method = Modelica_LinearSystems2.Types.Method.Trapezoidal
function fromMatrices import Modelica; import Modelica_LinearSystems2; import Modelica_LinearSystems2.DiscreteStateSpace; input Real A[:, size(A, 1)] "State matrix" annotation( Dialog(group = "new_x = A*x + B*u; y = C*x + D*u; x_cont = x + B2*u")); input Real B[size(A, 1), :] "Input matrix" annotation( Dialog(group = "new_x = A*x + B*u; y = C*x + D*u; x_cont = x + B2*u")); input Real C[:, size(A, 1)] "Output matrix" annotation( Dialog(group = "new_x = A*x + B*u; y = C*x + D*u; x_cont = x + B2*u")); input Real D[size(C, 1), size(B, 2)] "Feedforward matrix" annotation( Dialog(group = "new_x = A*x + B*u; y = C*x + D*u; x_cont = x + B2*u")); input Modelica.Units.SI.Time Ts = 1 "Sample time" annotation( Dialog(group = "Data used to construct discrete from continuous system")); input Real B2[:, :] = zeros(size(B, 1), size(B, 2)) "Reconstruct continuous state"; input Modelica_LinearSystems2.Utilities.Types.Method method = Modelica_LinearSystems2.Utilities.Types.Method.Trapezoidal "Discretization methodDiscretization method" annotation( Dialog(group = "Data used to construct discrete from continuous system")); output DiscreteStateSpace result(redeclare Real A[size(A, 1), size(A, 2)], redeclare Real B[size(B, 1), size(B, 2)], redeclare Real C[size(C, 1), size(C, 2)], redeclare Real D[size(D, 1), size(D, 2)], redeclare Real B2[size(B2, 1), size(B2, 2)]); end fromMatrices;