ReadRealMatrixFromFileDemonstrate usage of function Streams.readRealMatrix |
This information is part of the Modelica Standard Library maintained by the Modelica Association.
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.
file |
Value: Modelica.Utilities.Files.loadResource("modelica://Modelica/Resources/Data/Utilities/Test_RealMatrix_v4.mat") Type: String Description: File name of matrix |
---|---|
matrixName |
Value: "Matrix_A" Type: String Description: Matrix name in file |
dim |
Value: Modelica.Utilities.Streams.readMatrixSize(file, matrixName) Type: Integer[2] Description: Dimension of matrix |
A |
Value: Modelica.Utilities.Streams.readRealMatrix(file, matrixName, dim1[1], dim1[2]) Type: Real[:,:] Description: Matrix data |
file1 |
Value: Modelica.Utilities.Files.loadResource("modelica://Modelica/Resources/Data/Utilities/Test_RealMatrix_v4.mat") Type: String Description: File name of check matrix 1 |
file2 |
Value: Modelica.Utilities.Files.loadResource("modelica://Modelica/Resources/Data/Utilities/Test_RealMatrix_v6.mat") Type: String Description: File name of check matrix 2 |
file3 |
Value: Modelica.Utilities.Files.loadResource("modelica://Modelica/Resources/Data/Utilities/Test_RealMatrix_v7.mat") Type: String Description: File name of check matrix 3 |
matrixName1 |
Value: "Matrix_A" Type: String Description: Names of check matrices |
dim1 |
Value: Modelica.Utilities.Streams.readMatrixSize(file1, matrixName1) Type: Integer[2] Description: Dimension of check matrix 1 |
dim2 |
Value: Modelica.Utilities.Streams.readMatrixSize(file2, matrixName1) Type: Integer[2] Description: Dimension of check matrix 2 |
dim3 |
Value: Modelica.Utilities.Streams.readMatrixSize(file3, matrixName1) Type: Integer[2] Description: Dimension of check matrix 3 |
A1 |
Value: Modelica.Utilities.Streams.readRealMatrix(file1, matrixName1, dim1[1], dim1[2]) Type: Real[:,:] Description: Data of check matrix 1 |
A2 |
Value: Modelica.Utilities.Streams.readRealMatrix(file2, matrixName1, dim2[1], dim2[2]) Type: Real[:,:] Description: Data of check matrix 2 |
A3 |
Value: Modelica.Utilities.Streams.readRealMatrix(file3, matrixName1, dim3[1], dim3[2]) Type: Real[:,:] Description: Data of check matrix 3 |