WOLFRAM

File FormatsSimulation Result Files

Simulation Result FilesInformative Matrices
Headers

System Modeler uses a number of different file formats. For a complete list, see the System Modeler File Formats page.

Simulation Result Files

Simulation result files (.mat) are generated during simulations. The files are read by Simulation Center, but may also be accessed from within the Wolfram Language to extract specific values or datasets.

At the end of each simulation, the results of the simulation are stored in a level-4 MAT-file according to this specification. This binary file has a structure that can be interpreted as a sequence of matrices: Aclass, name, description, dataInfo, data_1, ..., data_n.

There are two different ways in which the matrices may be stored.

Headers

Each matrix is preceded by a header with six entries. The first five entries contain information about what data is stored and how, while the sixth entry is the name of the matrix.

type

An integer with storage information. If the integer is represented as M0PT, where M is the thousands digit, 0 is the hundreds digit, P is the tens digit, and T is the ones digit, then:

mrows

An integer specifying the number of rows in the matrix.

ncols

An integer specifying the number of columns in the matrix.

imagf

An integer specifying whether the matrix has an imaginary part. If set to 0, there is only real data; if set to 1, the matrix has an imaginary part.

namlen

An integer specifying the length in bytes plus one (null terminated) of the matrix name.

name

A null-terminated string of namlen ASCII bytes.

Informative Matrices

The matrices Aclass, name, and description are of type char, while the dataInfo matrix is of type int32_t. Each of the matrices contains information about the simulation and the variables.

Aclass

Aclass is a matrix with a (4,*) size; the number of columns depends on the lengths of the strings they contain. The information you get from this matrix is the format of the file (file format version and storage format) as well as the model name.

Below is a simplified and schematic representation of the matrix Aclass.

--------------------------------------
Atrajectory
1.1
GettingStarted.MultiDomain.DCMotor
binTrans
--------------------------------------

The first line is always the mandatory string Atrajectory. The second line is the version of the file format. The third line is the full name of the simulated model. The fourth and last line determine the format of the matrices that follow.

The version can be 1.1 or 1.2. If the version is 1.2, there is a fifth line added at the end, describing how the time vector is stored in data matrices. If the fifth line is timeDiff, the first time point contains the simulation start time, and each entry after that contains the time increment since the point before it. If the fifth line is time, each time entry is the time value stored normally.

name

The name matrix contains the names of the variables in the file, including states, variables, parameters, constants, and so on. The th row contains the name of the th variable. The global length of a row depends on the maximal length of all the strings.

Below is a simplified and schematic representation of the name matrix.

--------------------------------------
Time
inductor1.i
inertial.phi
...
...
--------------------------------------

description

This third matrix contains description texts for all variables. This corresponds to the strings you may add when defining a variable in Modelica. If nVars is the total number of variables, the matrix description is an (nVars,*)-sized matrix.

Below is a simplified and schematic representation of the description matrix.

--------------------------------------
Time
Current flowing from pin p to n [A]
Absolute rotation angle of component
...
...
--------------------------------------

If a variable does not have an associated description, the line is filled with blanks.

dataInfo

This fourth matrix dataInfo is an (nVars,4)-sized matrix of type int32_t, where nVars is the total number of variables. The matrix contains information on how and where each variable is stored in the data matrices. The th row describes the th variable.

Here is the correspondence between column values and their meaning:

Data Matrices

There can be several matrices for a simulation, and each of them has a specific name data_<index>, where <index> is the index of the matrix. Data matrices are always of type double. The information concerning these matrices is extracted from the previous matrix, dataInfo, as is the location of the values of interest.