This example demonstrates the computatrion of a LQR controller by calling function StateSpace.Design.lqr.
function designLQR extends Modelica.Icons.Function; import Modelica_LinearSystems2.StateSpace; input StateSpace ssi = StateSpace(A = [0, 1, 0, 0; 0, 0, 39.2, 0; 0, 0, 0, 1; 0, 0, 49, 0], B = [0; 1; 0; 1], C = [1, 0, 0, 0], D = [0]); input Boolean systemOnFile = false "True, if state space system is defined on file" annotation( Dialog(group = "system data definition"), choices(checkBox = true)); input String fileName = "NoName" "file where matrix [A, B; C, D] is stored" annotation( Dialog(group = "system data definition", loadSelector(filter = "MAT files (*.mat);; All files (*.*)", caption = "state space system data file"), enable = systemOnFile)); input String matrixName = "ABCD" "Name of the state space system matrix" annotation( Dialog(group = "system data definition", enable = systemOnFile)); output Boolean ok; end designLQR;