.Modelica_LinearSystems2.DiscreteStateSpace.'constructor'.fromMatrices2

Information

This function derives a linear time invariant difference equation system in state space form:

xd(Ts*(k+1))       = Ad * xd(Ts*k) + Bd * ud(Ts*k)
yd(Ts*k)           = Cd * xd(Ts*k) + Dd * ud(Ts*k)
x_continuous(Ts*k) =      xd(Ts*k) + B2 * ud(Ts*k)

from the matrices A, B, C, D of the corresponding continuous system

der(x(t)) = A * x(t) + B * u(t)
    y(t)  = C * x(t) + D * u(t)

The function is similar to fromStateSpace but the inputs are restricted to the matrices, the sample time and the discretization method.

Example

  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'.fromMatrices2(A, B, C, D);

  //or just:
  //dss := dss(A, B, C, D, Ts=0.1, method=Modelica_LinearSystems2.Types.Method.Trapezoidal);

  //  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

Interface

encapsulated function fromMatrices2
  import Modelica;
  import MatricesMSL = Modelica.Math.Matrices;
  import Modelica_LinearSystems2;
  import Modelica_LinearSystems2.Utilities.Types.Method;
  input Real A[:, size(A, 1)] annotation(
    Dialog(group = "der(x) = A*x + B*u;  y = C*x + D*u"));
  input Real B[size(A, 1), :] annotation(
    Dialog(group = "der(x) = A*x + B*u;  y = C*x + D*u"));
  input Real C[:, size(A, 1)] annotation(
    Dialog(group = "der(x) = A*x + B*u;  y = C*x + D*u"));
  input Real D[size(C, 1), size(B, 2)] annotation(
    Dialog(group = "der(x) = A*x + B*u;  y = C*x + D*u"));
  input Modelica.Units.SI.Time Ts "Sample time";
  input Modelica_LinearSystems2.Utilities.Types.Method method = Modelica_LinearSystems2.Utilities.Types.Method.Trapezoidal "Discretization method";
  output Modelica_LinearSystems2.DiscreteStateSpace dss(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(B, 1), size(B, 2)]) "Discrete state space system";
end fromMatrices2;

Generated at 2024-04-25T18:15:59Z by OpenModelicaOpenModelica 1.22.3 using GenerateDoc.mos