Main Content

MAT-file logging


Specify MAT-file logging. When using Embedded Coder® for a component model that is configured with a service interface, this parameter is not relevant and, therefore, is not supported.

Category: Code Generation > Interface


Default: on for the GRT target, off for ERT-based targets


Enable MAT-file logging. When you select this option, the generated code saves to MAT-files simulation data specified in one of the following ways:

In simulation, this data would be written to the MATLAB® workspace, as described in Export Simulation Data and Configure Signal Data for Logging. Setting MAT-file logging redirects the data to a MAT-file instead. The file is named model.mat, where model is the name of your model.


Disable MAT-file logging. Clearing this option has the following benefits:

  • Eliminates overhead associated with supporting a file system, which typically is not a requirement for embedded applications

  • Eliminates extra code and memory usage required to initialize, update, and clean up logging variables

  • Under certain conditions, eliminates code and storage associated with root output ports

  • Omits the comparison between the current time and stop time in the model_step, allowing the generated program to run indefinitely, regardless of the stop time setting


  • When you select MAT-file logging, you must also select the configuration parameters Support: non-finite numbers and, if you use an ERT-based system target file, Support: floating-point numbers.

  • Selecting this option enables MAT-file variable name modifier.

  • For ERT-based system target files, clear this parameter if you are using exported function calls.


  • The code generator does not support MAT-file logging for custom data types (data types that are not built into Simulink®).

  • MAT-file logging does not support file-scoped data, for example, data items to which you apply the built-in storage class FileScope.

  • In a referenced model, only the following data logging features are supported:

    • To File blocks

    • State logging — the software stores the data in the MAT-file for the top model.

  • In the context of the Embedded Coder product, MAT-file logging does not support the following IDEs: Analog Devices® VisualDSP++®, Texas Instruments™ Code Composer Studio™, Wind River® DIAB/GCC.

  • MAT-file logging does not support Outport blocks to which you apply the storage class ImportedExternPointer or storage classes that yield nonaddressable data in the generated code. For example, the storage class GetSet causes the Outport to appear in the generated code as a function call, which is not addressable. This limitation applies whether you apply the storage class directly by using, for example, the Model Data Editor, or by resolving the Outport to a Simulink.Signal object that uses the storage class. As a workaround, apply the storage class to the signal that enters the Outport block.

Command-Line Information

Parameter: MatFileLogging
Type: character vector
Value: 'on' | 'off'
Default: 'on' for the GRT target, 'off' for ERT-based targets

Recommended Settings

TraceabilityNo impact
Safety precautionOff

Related Topics