The data format for model-based exporting of simulation data specifies how Simulink® stores the exported data.
Simulink uses different data formats, depending on the kind of data that you export. For details, see:
When you log data store data, Simulink uses a
For details, see Accessing Data Store Logging Data.
For exported time, states, and output data, use one of the following formats:
If you select the Configuration Parameters > Data Import/Export > Output check box, Simulink logs fixed-point data as double. To log fixed-point data, consider using one of these approaches:
Signal logging — For details, see Export Signal Data Using Signal Logging.
In the Simulink Editor, select one or more signals.
Click the Simulation Data Inspector button arrow and click Log Selected Signals to Workspace.
To File block
To Workspace block — In the To Workspace Block Parameters dialog box, enable the Log fixed-point data as a fi object parameter.
For information about the format for logged final state data, see State Information.
timeseries objects to store logged data. MATLAB
allow you to work with logged data in MATLAB without a Simulink license.
Supports logging multiple data values for a given time step, which can be important for Iterator subsystem and Stateflow® signal logging.
Supports inclusion of units information in logged data for output data
Does not support logging nonvirtual bus data for code generation or in rapid accelerator mode.
If you select this
Array option, Simulink saves
the states and outputs of a model in a state and output array, respectively.
The state matrix has the name specified in the Configuration Parameters > Data
Import/Export pane (for example,
Each row of the state matrix corresponds to a time sample of the states
of a model. Each column corresponds to an element of a state. For
example, suppose that your model has two continuous states, each of
which is a two-element vector. Then the first two elements of each
row of the state matrix contain a time sample of the first state vector.
The last two elements of each row contain a time sample of the second
The model output matrix has the name specified in the Configuration Parameters > Data
Import/Export pane (for example,
Each column corresponds to a model output port, and each row to the
outputs at a specific time.
Note: Use array format to save your model outputs and states only if the logged data meets all these conditions:
If your model outputs and states do not meet these conditions,
If you select this format, Simulink saves the model states
and outputs in structures that have their names specified in the Configuration Parameters > Data
Import/Export pane. By default, the structures
xout for states and
The structure used to save outputs has two top-level fields:
Contains a vector of the simulation times.
Contains an array of substructures, each of which corresponds to a model output port.
Each substructure has four fields:
Contains the outputs for the corresponding output port.
If outputs are scalars or vectors —
is a matrix each of whose rows represent an output at the time specified
by the corresponding time vector element.
If the outputs are matrix (2-D) values —
is a 3-D array of dimensions M-by-N-by-T. M-by-N is the dimensions
of the output signal and T is the number of output samples.
If T = 1 — MATLAB drops the last dimension.
values field is an M-by-N matrix.
Specifies the dimensions of the output signal.
Specifies the label of the signal connected to the output port,
S-Function block, or the type of state (continuous or discrete). The
for S-Function block state labels. For S-Function block state labels
for discrete states, the label is the name of the state (instead of
Specifies the name of the corresponding output port or block with states.
signals field records the final state
of a block that resides in the reference model, contains a value of
Otherwise, the value is false (
The following example shows the structure-with-time format for a nonreferenced model.
ans = values: [296206x1 double] dimensions: 1 label: 'CSTATE' blockName: 'vdp/x1' inReferencedModel: 0
The structure used to save states has a similar organization. The states structure has two top-level fields:
time field contains a vector of the simulation
The field contains an array of substructures, each of which corresponds to one of the states of the model.
signals structure has four fields:
contains time samples of a state of the block specified by the
label field for built-in blocks indicates the
type of state: either
CSTATE (continuous state)
DSTATE (discrete state). For S-Function blocks,
the label contains whatever name is assigned to the state by the S-Function
The time samples of a state are stored in the
as a matrix of values. Each row corresponds to a time sample. Each
element of a row corresponds to an element of the state. If the state
is a matrix, the matrix is stored in the
in column-major order. For example, suppose that the model includes
a 2-by-2 matrix state and that 51 samples of the state are logged
during a simulation run.
values field for this state would contain
a 51-by-4 matrix. Each row corresponds to a time sample of the state,
and the first two elements of each row correspond to the first column
of the sample. The last two elements correspond to the second column
of the sample.
Simulink can read back simulation data saved to the MATLAB workspace
This format is the same as for
Structure with time output
format, except that Simulink does not store simulation times
time field of the saved structure.