readStateMatrix impure function
Requirements.LinearAnalysis.readStateMatrix
· source
The A matrix of a linearization from a MATLAB v4 file
Extends Modelica.Icons.Function
Modelica.Utilities.Streams.readRealMatrix on a MATLAB v4 file that holds the state matrix
of a linearization under the name matrixName (default A); other matrices in the
file (B, C, D, the operating point) are ignored. How to produce such
a file in different tools is described in LinearAnalysis.
v4 is the format every tool's ModelicaIO reads without a compression library.
The number of states is an input, not read from the file: an array dimension must be a structural
parameter, so the check model states it (it is the size of the linearized model's state vector). The
path is the caller's loadResource of the URI, in a parameter of its own: some tools fold
loadResource at translation and refuse to evaluate an impure function that calls it there,
while the read itself must happen at initialization (the matrix is a parameter with
fixed = false and an initial equation).
Copyright © 2026 Model Based Innovation LLC. All rights reserved.
Inputs
| Name | Type | Description |
|---|---|---|
filePath input | String | The file's path -- a modelica:// URI resolved by the caller (parameter String filePath = Modelica.Utilities.Files.loadResource(fileName)), so that the compiler folds the URI and leaves this impure read to initialization |
nx input | Integer | The number of states (the matrix is nx x nx; the caller knows it, the file's own size is not a structural parameter) |
matrixName input | String | The matrix's name in the file |
Outputs
| Name | Type | Description |
|---|---|---|
A[…] output | Real | The state matrix |