Most of the data streaming and logging methods in Simulink Real-Time rely on Simulation Data Inspector (SDI). This includes normal signal logging and the File Log block. Unfortunately, SDI has limited support for deployment. While it is possible to view live streaming data in a MATLAB app while the model is running, it is not possible to "log" it to a proper dataset.
Depending on the MATLAB release you are using to design and compile the app, here are the available options for file log handling:
File Log & Standalone App support in R2023a and newer
In R2023a and later, the SDI backend database is available for deployment, but SDI visualization is not yet possible.
This means you can use the File Log import function "tg.FileLog.import" in a standalone app to download the log file to the SDI backend database. With this, you can:
- Access the imported data using SDI APIs for custom plots or post-processing.
- Export the imported data into a variable or .mat file using the slrealtime.exportRun API.
- Other APIs such as "tg.FileLog.list" and "tg.FileLog.discard" should also work.
Note that you cannot open the actual SDI GUI to inspect the logged data from a standalone app.
New feature in R2023b: You can add a dedicated ImportFileLogButton button to your App Designer app to import a file log from a real-time application run to the host computer.
File Log & Standalone App support in R2022b and earlier
In R2022b and earlier, SDI cannot be deployed with MATLAB Compiler at all. This means it is not possible to access the streamed/logged data from a deployed application. Consequently, the regular file log import function "tg.FileLog.import" does not work in deployed standalone applications in R2022b and earlier.
While not ideal, there is a potential workaround. You can use File Log blocks to log data and disable "AutoImportFileLog" when you start the application. This way, the File Log data will remain on the target PC's hard drive until it is manually downloaded. Since "tg.FileLog.import" does not work in deployed standalone applications in R2022b and earlier, you can try manually copying over the File Log files and then importing them to MATLAB later.
However, please note that once the data is copied over, it can only be imported in a MATLAB session and not within a deployed app. The raw data can only be imported through SDI and not elsewhere. You can refer to the following documentation page for information on importing manually copied file logs:
The provided MATLAB Answers post also offers useful insights on the manual file log import workflow and how to use MATLAB's built-in "ftp" function for this purpose: