To write real-time signal data to a local file on your Speedgoat target computer's SSD, use the File Log block from R2020b onwards. File logging is a lossless and robust method to record many signals at very high data rates. All signals are recorded in one single log file on the target. The data is logged when no host computer is connected, making it ideal for standalone use. The logged data can be imported into MATLAB and viewed after Simulink Real-Time stops writing to it. To get started with file logs, see the following documentation pages:
This article covers the various stages of using file logs with Simulink Real-Time: Prepare model for file logging
Connect all signals that you would like to record to File Log blocks. Adding new signals to file logging after compiling the application is not possible. File Log blocks support common signal types, including array and bus signals.To enable and disable the file logging recording service using a control signal, connect an Enable File Log block to it. It is also possible to enclose File Log blocks in Enabled Subsystems to exclude certain signals from logging. Other conditional block execution semantics like for-iterator, function-call, or triggered subsystem are also supported. Each File Log block has a 'Decimation' parameter to reduce samples without changing the signal rate. The decimation can be changed for every simulation run by using File Log decimation functions (R2022a+). .
Start and stop logging during simulation
Import file logs to host computer
There are different ways to import completed file log runs to the host computer:
• Automatic file log import (default): If the MATLAB host computer is connected during the run, file logs are automatically transferred at the end of the run. This behavior is enabled by default.
• Interactive file log import: If the host computer is not connected when the run stops, or the
'AutoImportFileLog' option is disabled, you can import file logs manually using one of the following options:
- MATLAB API: Use the tg.FileLog.import command in a script or directly from the MATLAB Command Window.
- 'Import File Log' dialog: Open the dialog by pressing the corresponding button in SLRT Explorer, in the Real-Time tab of your model, or in your custom SLRT app via an ImportFileLogButton (R2023b+). You can also use the openImportDialog command to launch the dialog programmatically.
.
View, store, and post-process logged data
Imported file log runs automatically load to the Simulation Data Inspector (SDI). In addition, the data is saved to the 'logsout' variable in the MATLAB base workspace, unless the 'ExportToBaseWorkspace' option is disabled. ⚠️ Data loss warning: In MATLAB R2020b through R2022a, File log runs are deleted from the target SSD after transfer to the host computer. This means that you must save the data from SDI or the base workspace before closing MATLAB. If you close MATLAB without saving the data, your logged data is lost. We recommend upgrading to R2022b and later, where auto-deletion of imported file logs does not occur.