modelReadRealMatrixFromFile
Demonstrate usage of function Streams.readRealMatrix
Extends from Modelica.Icons.Example (Icon for runnable examples).
Information
Example model that shows how to read a Real matrix in MATLAB MAT format from file using functions readMatrixSize and readRealMatrix.
Additionally, specific matrices from the supported file formats are loaded and it is checked whether the loaded matrices have the expected values.
Parameters
| Type | Name | Default | Description |
|---|---|---|---|
| String | file | Modelica.Utilities.Files.loadResource("modelica://Modelica/Resources/Data/Utilities/Test_RealMatrix_v4.mat") | File name of matrix |
| String | matrixName | "Matrix_A" | Matrix name in file |
| Integer[2] | dim | Modelica.Utilities.Streams.readMatrixSize(file, matrixName) | Dimension of matrix |
| Real[:,:] | A | Modelica.Utilities.Streams.readRealMatrix(file, matrixName, dim[1], dim[2]) | Matrix data |
| String | file1 | Modelica.Utilities.Files.loadResource("modelica://Modelica/Resources/Data/Utilities/Test_RealMatrix_v4.mat") | File name of check matrix 1 |
| String | file2 | Modelica.Utilities.Files.loadResource("modelica://Modelica/Resources/Data/Utilities/Test_RealMatrix_v6.mat") | File name of check matrix 2 |
| String | file3 | Modelica.Utilities.Files.loadResource("modelica://Modelica/Resources/Data/Utilities/Test_RealMatrix_v7.mat") | File name of check matrix 3 |
| String | matrixName1 | "Matrix_A" | Names of check matrices |
| Integer[2] | dim1 | Modelica.Utilities.Streams.readMatrixSize(file1, matrixName1) | Dimension of check matrix 1 |
| Integer[2] | dim2 | Modelica.Utilities.Streams.readMatrixSize(file2, matrixName1) | Dimension of check matrix 2 |
| Integer[2] | dim3 | Modelica.Utilities.Streams.readMatrixSize(file3, matrixName1) | Dimension of check matrix 3 |
| Real[:,:] | A1 | Modelica.Utilities.Streams.readRealMatrix(file1, matrixName1, dim1[1], dim1[2]) | Data of check matrix 1 |
| Real[:,:] | A2 | Modelica.Utilities.Streams.readRealMatrix(file2, matrixName1, dim2[1], dim2[2]) | Data of check matrix 2 |
| Real[:,:] | A3 | Modelica.Utilities.Streams.readRealMatrix(file3, matrixName1, dim3[1], dim3[2]) | Data of check matrix 3 |
Components
| Type | Name | Default | Description |
|---|---|---|---|
| Real | x | Dummy state |