functionfromFile
Read a DiscreteStateSpace data record from mat-file
Information
Syntax
| dss | = | DiscreteStateSpace.Import.fromFile(fileName, matrixName) |
Description
Reads and loads a discrete state space system from a mat-file fileName. The discrete System on the file must be described as:
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 (for more details see DiscreteStateSpace.'constructor'.fromStateSpace):
- Ts - the sample time,
- k - the index of the actual sample instance (k=0,1,2,3,...),
- t - the time,
- u(t) - the input vector,
- y(t) - the output vector,
- x(t) - the discrete state vector (x(t=Ts*0) is the initial state),
- x_continuous(t) - the state vector of the continuous system from which the discrete block has been derived,
- A, B, C, D, B2 - matrices of appropriate dimensions.
The file must contain
- the Real matrix [A, B; C, D] with name "matrixName",
- the Integer matrix "nx[1,1]" defining the number of states (that is the number of rows of the square matrix A),
- the Real matrix B2 that has the same dimensions as B,
- the Real matrix "Ts[1,1]" defining the sample time in [s] with which the continuous-time system was discretized to arrive at this discrete system
Example
algorithm
file := Modelica.Utilities.Files.loadResource("resources/Modelica_LinearSystems2/Resources/Data/dss.mat")
dss:=Modelica_LinearSystems2.DiscreteStateSpace.Import.fromFile(file)
// dss=StateSpace(
A=[-4.5, 1.5, 4.0; -4.0, 1.0, 4.0; -1.5, -0.5, 1],
B=[2; 1; 2],
C=[1, 0, 0],
D=[0],
B2=[0;0;0],
Ts=0.2,
method=Trapezoidal);
Inputs
| Type | Name | Default | Description |
|---|---|---|---|
| String | fileName | "dslin.mat" | Name of the state space system data file |
| String | matrixName | "ABCD" | Name of the state space system matrix |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| DiscreteStateSpace | result | = model linearized at initial point |