Main Content

MAT-file logging

Exported data saved in MAT-file

Model Configuration Pane: Code Generation / Interface

Description

The MAT-file logging parameter specifies whether the code generator saves exported data to a MAT-file.

  • This parameter is not supported for models that are configured with an ERT-based system target file and service code interface.

  • If you select this parameter, you must select the Support: non-finite numbers parameter. If the System target file parameter is set to an ERT-based system target file, you must also select the Support: floating-point numbers parameter.

  • Selecting this parameter enables the MAT-file variable name modifier parameter.

  • If the System target file parameter is set to an ERT-based system target file, and the model uses exported function calls, clear this parameter.

Settings

On (default for GRT-based system target files) | Off (default for ERT-based system target files)
On

Enables MAT-file logging. This is the default setting for models configured with a GRT-based system target file.

The generated code saves exported data to a MAT-file in one of these ways:

For more information, see Save Simulation Data and Configure Signal Data for Logging.

The MAT-file is named model.mat, where model is the name of your model.

Off

Disable MAT-file logging. This is the default setting for models configured with a ERT-based system target file.

Clearing this option has these 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.

Recommended Settings

ApplicationSetting
DebuggingOn
TraceabilityNo impact
EfficiencyOff
Safety precautionOff

Programmatic Use

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

Limitations

  • MAT-file logging does not support Signal logging. The logsout variable is not saved to the MAT-file.

  • 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 these 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 these 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 Explorer, 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.

  • If you build a standalone executable file for your development computer with the Allow tasks to execut concurrently on target parameter selected, the generated main function does not include calls to save a MAT-file. When you run the executable file on your development computer, the executable file does not generate a MAT-file.

Version History

Introduced before R2006a