## Modelica_LinearSystems2.Examples.StateSpace

Package with examples to demonstrate the usage of the StateSpace record

### Information

This package contains example function calls to demonstrate the usage of the functions of the StateSpace record.

Extends from Modelica.Icons.ExamplesPackage (Icon for packages containing runnable examples).

### Package Content

Name | Description
--- | ---
analysis | Example to check controllability of a state space system
analysisDcGain | Example to compute dcGain of a state space system
analysisControllability | Example to check controllability of a state space system
analysisObservability | Example to check controllability of a state space system
analysisControllablePoles | Example to check controllability of a state space system and print the controllable poles
analysisTimeResponse | Compute time response of a state space system
analysisInitialResponse | Initial response example
analysisImpulseResponse | Impulse response example
analysisStepResponse | Step response example
analysisPolesAndZerosSISO | Compute poles and invariant zeros of a SISO state space system by transformation to a minmal system
analysisInvariantZeros | Example to compute the invariant zeros of a state space system
analysisStairCase | Example to check controllability of a state space system
conversionFromZerosAndPoles | Transform a TransferFunction into a StateSpace description
conversionToTransferFunctionMIMO | Example to compute a transfer function matrix of a MIMO system from state space representation
conversionToTransferFunctionSISO | Example to compute a transfer function from SISO state space representation
conversionToZerosAndPolesMIMO | Example to compute a zeros-and-poles representation of a MIMO system from state space representation
conversionToZerosAndPolesSISO | Example to compute a zeros and poles representation from SISO state space representation
designAssignPolesSISO | Example for pole placing using Ackermann's method
designAssignPolesMIMO | Example for pole placing
designKalmanFilter | Example for Kalman filter design
designLQG | Example for LQG controller design
designLQR | Example for LQR controller design
plotPolesAndZeros | Example for plotting eigenvalues and invariant zeros of a state space system
plotBodeMIMO | Constructs zeros-and-poles-transfers from state space representation and plots the Bode diagrams with automatic determination of the frequency range to plot
plotBodeSISO | Constructs a zeros-and-poles-transfer function from state space representation and plots the Bode diagram with automatic determination of the frequency range to plot
plotTimeResponse | Time response plot example
plotImpulse | Impulse plot example
plotInital | Initial condition plot example
plotRamp | Plot ramp response
plotStep | Step plot example
plotZeros | Case studies of systems with zeros
transformation | Example to demonstrate the transformation to Jordan- observabilitiy- and controllability canonical form
transformationExtract | Example how to extract input/output related subsystems from state space system record
transformationToIrreducibleForm | Example to compute the minimal state space realization of a given SISO state space realization

## Modelica_LinearSystems2.Examples.StateSpace.analysis

Example to check controllability of a state space system

### Information

This example shows the usage of function Modelica_LinearSystems2.StateSpace.Analysis.isControllable which is to check whether a system is controllable or not.

### Inputs

Name | Description
--- | ---
ssi |
analyseOptions |
system data definition
systemOnFile | true, if state space system is defined on file
fileName | file where matrix [A, B; C, D] is stored
matrixName | Name of the state space system matrix

### Outputs

Name | Description
--- | ---
ok |

## Modelica_LinearSystems2.Examples.StateSpace.analysisDcGain

Example to compute dcGain of a state space system

### Information

This example shows how to calculate the dc-gain of a state space system.

### Inputs

Name | Description
--- | ---
ssi |

### Outputs

Name | Description
--- | ---
ok |

## Modelica_LinearSystems2.Examples.StateSpace.analysisControllability

Example to check controllability of a state space system

### Information

This example shows the usage of function Modelica_LinearSystems2.StateSpace.Analysis.isControllable which is to check whether a system is controllable or not.

### Inputs

Name | Description
--- | ---
ssi |
system data definition
systemOnFile | true, if state space system is defined on file
fileName | file where matrix [A, B; C, D] is stored
matrixName | Name of the state space system matrix

### Outputs

Name | Description
--- | ---
ok |

## Modelica_LinearSystems2.Examples.StateSpace.analysisObservability

Example to check controllability of a state space system

### Information

This example shows the usage of function Modelica_LinearSystems2.StateSpace.Analysis.isObservable which is to check whether a system is observable or not.

### Inputs

Name | Description
--- | ---
ssi |
system data definition
systemOnFile | true, if state space system is defined on file
fileName | file where matrix [A, B; C, D] is stored
matrixName | Name of the state space system matrix

### Outputs

Name | Description
--- | ---
ok |

## Modelica_LinearSystems2.Examples.StateSpace.analysisControllablePoles

Example to check controllability of a state space system and print the controllable poles

### Information

This example shows the usage of function Modelica_LinearSystems2.StateSpace.Analysis.isControllable which is to check whether a system is controllable or not.

### Inputs

Name | Description
--- | ---
ssi |
system data definition
systemOnFile | true, if state space system is defined on file
fileName | file where matrix [A, B; C, D] is stored
matrixName | Name of the state space system matrix

### Outputs

Name | Description
--- | ---
ok |

## Modelica_LinearSystems2.Examples.StateSpace.analysisTimeResponse

Compute time response of a state space system

### Information

Computes the time response of the system StateSpace sc = StateSpace(A=[-1,1;0,-2],B=[1, 0;0, 1],C=[1,0; 0,1],D=[0, 0; 0, 0]), sampled at Ts=0.01 with inititial state x0=[0;0] subject to the system input u = ones(samples,2), (samples is set to 30).

### Inputs

Name | Description
--- | ---
sc |
response |
dt |
span |

### Outputs

Name | Description
--- | ---
y[samples, 2, 2] | System response (dimension: (input samples) x (number of outputs))
t[samples] | Time vector used for simulation
x[samples, 2, 2] | State trajectories (dimension: (input samples) x (number of states)

## Modelica_LinearSystems2.Examples.StateSpace.analysisInitialResponse

Initial response example

### Information

Computes and plots the initial response of a state space system by given initial values.

### Outputs

Name | Description
--- | ---
y[:, size(sc.C, 1), 1] | Output response: (number of samples) x (number of outputs) x 1

## Modelica_LinearSystems2.Examples.StateSpace.analysisImpulseResponse

Impulse response example

### Information

Computes and plots the impulse response of a state space system.

### Outputs

Name | Description
--- | ---
y[:, size(sc.C, 1), size(sc.B, 2)] | Output response: (number of samples) x (number of outputs) x (number of inuputs)

## Modelica_LinearSystems2.Examples.StateSpace.analysisStepResponse

Step response example

### Information

Computes and plots the step response of a state space system.

### Outputs

Name | Description
--- | ---
y[:, size(sc.C, 1), size(sc.B, 2)] | Output response: (number of samples) x (number of outputs) x (number of inuputs)

## Modelica_LinearSystems2.Examples.StateSpace.analysisPolesAndZerosSISO

Compute poles and invariant zeros of a SISO state space system by transformation to a minmal system

### Information

This example shows the computation of the poles and zeros of a SISO system and of its irreducible representation.

### Inputs

Name | Description
--- | ---
system data definition
fileName | file where matrix [A, B; C, D] is stored
matrixName | Name of the state space system matrix
system matrices
A[:, :] |
B[:, :] |
C[:, :] |
D[:, :] |

### Outputs

Name | Description
--- | ---
ok |

## Modelica_LinearSystems2.Examples.StateSpace.analysisInvariantZeros

Example to compute the invariant zeros of a state space system

### Information

This example shows the computation of the poles and zeros of state space system.

### Inputs

Name | Description
--- | ---
z[:] | Zeros (Complex vector of numerator zeros)
p[:] | Poles (Complex vector of denominator zeros)
k | Constant multiplied with transfer function

## Modelica_LinearSystems2.Examples.StateSpace.analysisStairCase

Example to check controllability of a state space system

### Information

This example shows the usage of the staircase algorithm to transform a state space system in staircase form to analyze controllability.

### Inputs

Name | Description
--- | ---
ssi |
system data definition
systemOnFile | true, if state space system is defined on file
fileName | file where matrix [A, B; C, D] is stored
matrixName | Name of the state space system matrix

### Outputs

Name | Description
--- | ---
ok |

## Modelica_LinearSystems2.Examples.StateSpace.conversionFromZerosAndPoles

Transform a TransferFunction into a StateSpace description

### Information

This example demonstrates the conversion of a zeros-and-poles system into a state space system.

### Inputs

Name | Description
--- | ---
zp |

### Outputs

Name | Description
--- | ---
ok |

## Modelica_LinearSystems2.Examples.StateSpace.conversionToTransferFunctionMIMO

Example to compute a transfer function matrix of a MIMO system from state space representation

### Information

This example demonstrates the conversion of a MIMO transfer function into a state space system.

### Inputs

Name | Description
--- | ---
system data definition
systemOnFile | true, if state space system is defined on file
fileName | file where matrix [A, B; C, D] is stored
matrixName | Name of the state space system matrix
system matrices
A[:, size(A, 1)] |
B[size(A, 2), :] |
C[:, size(A, 1)] |
D[size(C, 1), size(B, 2)] |

### Outputs

Name | Description
--- | ---
ok |

## Modelica_LinearSystems2.Examples.StateSpace.conversionToTransferFunctionSISO

Example to compute a transfer function from SISO state space representation

### Information

This example demonstrates the conversion of a SISO transfer function system into a state space system.

### Inputs

Name | Description
--- | ---
system data definition
systemOnFile | true, if state space system is defined on file
fileName | file where matrix [A, B; C, D] is stored
matrixName | Name of the state space system matrix
system matrices
A[:, :] |
B[:, :] |
C[:, :] |
D[:, :] |

### Outputs

Name | Description
--- | ---
ok |

## Modelica_LinearSystems2.Examples.StateSpace.conversionToZerosAndPolesMIMO

Example to compute a zeros-and-poles representation of a MIMO system from state space representation

### Information

This example demonstrates the conversion of a MIMO zeros-and-poles system into a state space system.

### Inputs

Name | Description
--- | ---
system data definition
systemOnFile | true, if state space system is defined on file
fileName | file where matrix [A, B; C, D] is stored
matrixName | Name of the state space system matrix
system matrices
A[:, size(A, 1)] |
B[size(A, 2), :] |
C[:, size(A, 1)] |
D[size(C, 1), size(B, 2)] |

### Outputs

Name | Description
--- | ---
ok |

## Modelica_LinearSystems2.Examples.StateSpace.conversionToZerosAndPolesSISO

Example to compute a zeros and poles representation from SISO state space representation

### Information

This example demonstrates the conversion of a SISO zeros-and-poles system into a state space system.

### Inputs

Name | Description
--- | ---
system data definition
systemOnFile | true, if state space system is defined on file
fileName | file where matrix [A, B; C, D] is stored
matrixName | Name of the state space system matrix
system matrices
A[:, :] |
B[:, :] |
C[:, :] |
D[:, :] |

### Outputs

Name | Description
--- | ---
ok |

## Modelica_LinearSystems2.Examples.StateSpace.designAssignPolesSISO

Example for pole placing using Ackermann's method

### Information

Computes the gain vector k for the state space system

    sc = StateSpace(A=[-1,1;0,-2],B=[0, 1],C=[1,0; 0, 1],D=[0; 0])

such that for the state feedback

    u = -k*y = -k*x

the closed-loop poles are placed at

    p = {-3,-4}.

Extends from Modelica.Icons.Function (Icon for functions).

### Inputs

Name | Description
--- | ---
sc |

### Outputs

Name | Description
--- | ---
k[2] | Gain vector

## Modelica_LinearSystems2.Examples.StateSpace.designAssignPolesMIMO

Example for pole placing

### Information

Computes the gain vector k for the state space system

    ss = StateSpace(A=[-1,1;0,-2],B=[0, 1],C=[1,0; 0, 1],D=[0; 0])

such that for the state feedback

    u = -k*y = -k*x

the closed-loop poles are placed at

    p = {-3,-4}.

Extends from Modelica.Icons.Function (Icon for functions).

### Inputs

Name | Description
--- | ---
ss |
p[:] |

### Outputs

Name | Description
--- | ---
K[:, :] | Gain vector
S[:, :] |

## Modelica_LinearSystems2.Examples.StateSpace.designKalmanFilter

Example for Kalman filter design

### Information

This example demonstrates the computatrion of a Kalman filter by calling function StateSpace.Design.kalmanFilter()

Extends from Modelica.Icons.Function (Icon for functions).

### Inputs

Name | Description
--- | ---
ss |

### Outputs

Name | Description
--- | ---
L[:, :] |
kss |

## Modelica_LinearSystems2.Examples.StateSpace.designLQG

Example for LQG controller design

### Information

This example demonstrates the computatrion of a LQG controllerr by calling function StateSpace.Design.lqg()

Extends from Modelica.Icons.Function (Icon for functions).

### Inputs

Name | Description
--- | ---
ssi |
system data definition
systemOnFile | true, if state space system is defined on file
fileName | file where matrix [A, B; C, D] is stored
matrixName | Name of the state space system matrix

### Outputs

Name | Description
--- | ---
ok |

## Modelica_LinearSystems2.Examples.StateSpace.designLQR

Example for LQR controller design

### Information

This example demonstrates the computatrion of a LQR controller by calling function StateSpace.Design.lqr()

Extends from Modelica.Icons.Function (Icon for functions).

### Inputs

Name | Description
--- | ---
ssi |
system data definition
systemOnFile | true, if state space system is defined on file
fileName | file where matrix [A, B; C, D] is stored
matrixName | Name of the state space system matrix

### Outputs

Name | Description
--- | ---
ok |

## Modelica_LinearSystems2.Examples.StateSpace.plotPolesAndZeros

Example for plotting eigenvalues and invariant zeros of a state space system

### Information

This example demonstrates the plotting of eigenvalues and invariant zeros of a state space system.

Extends from Modelica_LinearSystems2.StateSpace.Plot.polesAndZeros (Plot poles (i.e. eigenvalues) and/or invariant zeros of a state space system).

### Inputs

Name | Description
--- | ---
ss | Linear system in state space form
poles | = true, to plot the poles (i.e. the eigenvalues) of ss
zeros | = true, to plot the (invariant) zeros of ss
defaultDiagram | Default diagram layout
device | Properties of device where figure is shown

## Modelica_LinearSystems2.Examples.StateSpace.plotBodeMIMO

Constructs zeros-and-poles-transfers from state space representation and plots the Bode diagrams with automatic determination of the frequency range to plot

### Information

This example demonstrates the construnction of a zeros-and-poles-transfer-function-matrix from a MIMO state space representation and üplots the Bode diagrams with automatic determination of the frequency range to plot

### Inputs

Name | Description
--- | ---
system data definition
systemOnFile | true, if state space system is defined on file
fileName | file where matrix [A, B; C, D] is stored
system matrices
A[:, size(A, 1)] |
B[size(A, 2), :] |
C[:, size(A, 1)] |
D[size(C, 1), size(B, 2)] |

### Outputs

Name | Description
--- | ---
ok |

## Modelica_LinearSystems2.Examples.StateSpace.plotBodeSISO

Constructs a zeros-and-poles-transfer function from state space representation and plots the Bode diagram with automatic determination of the frequency range to plot

### Information

This example demonstrates the construnction of a zeros-and-poles-transfer-function from a SISO state space representation and üplots the Bode diagrams with automatic determination of the frequency range to plot

### Inputs

Name | Description
--- | ---
systemOnFile | true, if state space system is defined on file
fileName | file where matrix [A, B; C, D] is stored
A[:, size(A, 1)] |
B[size(A, 2), :] |
C[:, size(A, 1)] |
D[size(C, 1), size(B, 2)] |
iu | index of inout
iy | index of output

### Outputs

Name | Description
--- | ---
ok |

## Modelica_LinearSystems2.Examples.StateSpace.plotTimeResponse

Time response plot example

### Information

Computes the impulse response of the system StateSpace sc = StateSpace(A=[-1,1;0,-2],B=[1, 0;0, 1],C=[1,0; 0,1],D=[0, 0; 0, 0]).

### Inputs

Name | Description
--- | ---
response | type of time response
ss |

## Modelica_LinearSystems2.Examples.StateSpace.plotImpulse

Impulse plot example

### Information

Computes the impulse response of the system StateSpace sc = StateSpace(A=[-1,1;0,-2],B=[1, 0;0, 1],C=[1,0; 0,1],D=[0, 0; 0, 0]).

### Inputs

Name | Description
--- | ---
ss |

## Modelica_LinearSystems2.Examples.StateSpace.plotInital

Initial condition plot example

### Information

Computes the initial condition response of the system StateSpace sc = StateSpace(A=[-1,1;0,-2],B=[1, 0;0, 1],C=[1,0; 0,1],D=[0, 0; 0, 0]) to the initial condition x0=[1;1].

### Inputs

Name | Description
--- | ---
ss |

## Modelica_LinearSystems2.Examples.StateSpace.plotRamp

Plot ramp response

### Information

Computes the ramp response of the system StateSpace ss = StateSpace(A=[-1,1;0,-2],B=[1, 0;0, 1],C=[1,0; 0,1],D=[0, 0; 0, 0]).

### Inputs

Name | Description
--- | ---
ss |

## Modelica_LinearSystems2.Examples.StateSpace.plotStep

Step plot example

### Information

Computes and plots the step response of the system StateSpace ss = StateSpace(A=[-1,1;0,-2],B=[1, 0;0, 1],C=[1,0; 0,1],D=[0, 0; 0, 0]).

### Inputs

Name | Description
--- | ---
ss |

## Modelica_LinearSystems2.Examples.StateSpace.plotZeros

Case studies of systems with zeros

### Information

Computes the initial condition response of the system StateSpace sc = StateSpace(A=[-1,1;0,-2],B=[1, 0;0, 1],C=[1,0; 0,1],D=[0, 0; 0, 0]) to the initial condition x0=[1;1]. This example plots the output y and the states (x1, x2, x3) of a system with the input

>        u(t) = uk*exp(zk*t)

where zk is an invariant zero of the system. Assuming appropriate initial conditions, the output of the system is forced to zero. It is demonstrated that the output can also be forced to zero by applying a transient unstable input. Although the output is zero, the states show transient and unstable behavior. In comparison, the outputs as an reaction of inputs with half or double frequency are not equal to zero.

## Modelica_LinearSystems2.Examples.StateSpace.transformation

Example to demonstrate the transformation to Jordan- observabilitiy- and controllability canonical form

### Information

Example to demonstrate the transformation of a state space representation to Jordan- observabilitiy- and controllability canonical form

### Inputs

Name | Description
--- | ---
system data definition
fileName | file where matrix [A, B; C, D] is stored
matrixName | Name of the state space system matrix
system matrices
A[:, :] |
B[:, :] |
C[:, :] |
D[:, :] |

### Outputs

Name | Description
--- | ---
ok |

## Modelica_LinearSystems2.Examples.StateSpace.transformationExtract

Example how to extract input/output related subsystems from state space system record

### Information

This example shows how to extract input/output related subsystems from state space system record.

## Modelica_LinearSystems2.Examples.StateSpace.transformationToIrreducibleForm

Example to compute the minimal state space realization of a given SISO state space realization

### Information

This example shows the usage of function Modelica_LinearSystems2.StateSpace.reduceSystem which compute a controllable and observable state space realization of a given state space realization.

### Inputs

Name | Description
--- | ---
A[:, :] |
B[:, :] |
C[:, :] |
D[:, :] |
system data definition
fileName | file where matrix [A, B; C, D] is stored
matrixName | Name of the state space system matrix

### Outputs

Name | Description
--- | ---
ok |