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

TypeNameDefaultDescription
StringfileModelica.Utilities.Files.loadResource("modelica://Modelica/Resources/Data/Utilities/Test_RealMatrix_v4.mat")File name of matrix
StringmatrixName"Matrix_A"Matrix name in file
Integer[2]dimModelica.Utilities.Streams.readMatrixSize(file, matrixName)Dimension of matrix
Real[:,:]AModelica.Utilities.Streams.readRealMatrix(file, matrixName, dim[1], dim[2])Matrix data
Stringfile1Modelica.Utilities.Files.loadResource("modelica://Modelica/Resources/Data/Utilities/Test_RealMatrix_v4.mat")File name of check matrix 1
Stringfile2Modelica.Utilities.Files.loadResource("modelica://Modelica/Resources/Data/Utilities/Test_RealMatrix_v6.mat")File name of check matrix 2
Stringfile3Modelica.Utilities.Files.loadResource("modelica://Modelica/Resources/Data/Utilities/Test_RealMatrix_v7.mat")File name of check matrix 3
StringmatrixName1"Matrix_A"Names of check matrices
Integer[2]dim1Modelica.Utilities.Streams.readMatrixSize(file1, matrixName1)Dimension of check matrix 1
Integer[2]dim2Modelica.Utilities.Streams.readMatrixSize(file2, matrixName1)Dimension of check matrix 2
Integer[2]dim3Modelica.Utilities.Streams.readMatrixSize(file3, matrixName1)Dimension of check matrix 3
Real[:,:]A1Modelica.Utilities.Streams.readRealMatrix(file1, matrixName1, dim1[1], dim1[2])Data of check matrix 1
Real[:,:]A2Modelica.Utilities.Streams.readRealMatrix(file2, matrixName1, dim2[1], dim2[2])Data of check matrix 2
Real[:,:]A3Modelica.Utilities.Streams.readRealMatrix(file3, matrixName1, dim3[1], dim3[2])Data of check matrix 3

Components

TypeNameDefaultDescription
RealxDummy state