Data Format for Logged Simulation Data - MATLAB & Simulink (original) (raw)

Data Format for Block-Based Logged Data

You can use the Scope, To File, To Workspace, Playback, orRecord blocks to export simulation data. Each of these blocks has a data format parameter.

Data Format for Model-Based Logged Data

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:

Signal Logging Format

Signal logging always uses Dataset format. You can specify whether to log data for individual signals as timeseries or timetable objects.

To control how Dataset elements are saved, set the Dataset signal format configuration parameter. The default istimeseries. For details, see Dataset signal format.

The Dataset signal format parameter applies to signal logging, as well as output and states data when you set the Save format parameter to Dataset.

Logged Data Store Format

When you log data store data, Simulink uses a Simulink.SimulationData.Dataset object.

For details, see Accessing Data Store Logging Data.

Time, State, and Output Data Format

For exported time, states, and output data, use one of the following formats:

If you select the > > check box, Simulink logs fixed-point data as double. To log fixed-point data, consider using one of these approaches:

For information about the format for logged final state data, see Save Block States and Simulation Operating Points.

Dataset

By default, time, states, and outputs are logged using the Dataset format. The Dataset format:

Signal logging always uses the Dataset format. Logging states and output data using the Dataset format allows you to post-process simulation data without writing custom code for different types of logged data. When you log states and outputs using the Dataset format, the data also automatically streams to the Simulation Data Inspector during simulation.

Array

If you select this Array option, Simulink saves the states and outputs of a model in a state and in an output array, respectively.

The state matrix has the name specified in the > pane (for example, xout). 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 state vector.

The model output matrix has the name specified in the > pane (for example, yout). 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, use theStructure or Structure with time output formats (see Structure with Time).

Structure with Time

If you select this format, Simulink saves the model states and outputs in structures that have their names specified in the > pane. By default, the structures are xout for states andyout for output.

The structure used to save outputs has two top-level fields:

Each substructure has four fields:

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:

Each signals structure has four fields: values,dimensions, label, andblockName. The values field contains time samples of a state of the block specified by the blockName field. Thelabel field for built-in blocks indicates the type of state: eitherCSTATE (continuous state) or DSTATE (discrete state). For S-Function blocks, the label contains whatever name is assigned to the state by the S-Function block.

The time samples of a state are stored in the values field 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 thevalues array 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.

The 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.

Structure

This format is the same as for Structure with time output format, except that Simulink does not store simulation times in the time field of the saved structure.

See Also

Simulink.SimulationData.Dataset | Simulink.SimulationData.forEachTimeseries

Topics