Main Content

Log data to file

Option to log data that uses Dataset format to MAT or MLDATX file

Model Configuration Pane: Data Import/Export

Description

The Log data to file parameter specifies whether simulation data that uses the Dataset format is logged to a MAT or MLDATX file or logged to the workspace.

Log data to a MAT or MLDATX file by specifying the file extension as .mat or .mldatx. For example, to log data to an MLDATX file named myData, type myData.mldatx.

Logging data to an MLDATX file typically results in a smaller file size. The MLDATX file created when you select Log data to file is similar to a Simulation Data Inspector session file, but it contains only the data for a single run without view or comparison information.

This table shows the type of data that can be logged to each file type.

Logged DataFile Type
MAT fileMLDATX file
Output saved in Dataset formatYesYes
Signal logging dataYesYes
States saved in Dataset formatYesYes
Final states saved in Dataset formatYesNo
Data storesYesYes
Data logged using a Record blockNoYes
Data logged using a To Workspace blockNoYes
Data logged using a Scope block configured to log data to the workspaceNoYes

To log states or output data to a file, set the Save format parameter to Dataset.

To log Final states data to a MAT file, set the Save format parameter to Dataset and clear Save final operating point. MLDATX files do not support logging Final states data.

Tip

To log operating point data to a MAT file, log the model operating point during simulation. For more information, see Speed Up Simulation Workflows by Using Model Operating Points.

Settings

off (default) | on
off

Simulation data logged using the Dataset format logs to the workspace and does not log to a file.

on

Simulation data logged using Dataset format logs to a MAT or MLDATX file and does not log to the workspace. By default, data is saved in a MAT file with the name out.mat in the current working directory. To log data to an MLDATX file, change the file extension to .mldatx. To save the file in a different location or using a different filename, specify the path and filename in the text box.

Tips

Note

To log data to an MLDATX file, in Preferences > Storage, check that the default setting of View and record data is selected. If you select View during simulation only instead, the MLDATX file contains the logged signal name, but does not include the data.

Recommended Settings

The table summarizes recommended values for this parameter based on considerations related to code generation.

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
Efficiency

No recommendation

Safety precaution

No recommendation

Programmatic Use

Parameter: LoggingToFile
Value: "on" | "off"
Default: 'off'
Parameter: LoggingFileName
Type: string | character vector
Value: valid path and file name
Default: 'out.mat'

Version History

Introduced in R2016a

expand all