No. In general, the 'To File' block is used for simulation on desktop and is not recommended for code generation workflows, as documented in the "Extended Capabilities" section of the block documentation:
The block will in fact not perform any functionality when used in a simulation with Simulink Real-Time (SLRT) and Speedgoat.
Try This Workaround
Instead, use recommended signal logging options for SLRT such as file logging and live streaming to Simulation Data Inspector (SDI).
For the file logging approach, file logs are written to the Speedgoat target SSD for robust and lossless data logging. File logs can be automatically imported into MATLAB's SDI when stopping a run, and will create a 'logsout' variable in the workspace by default for later post-processing and export to file. However, note that the raw data recorded on the target SSD is binary and can only be viewed in MATLAB's SDI, and there is no way to directly save the file logs in a different portable format.
For the live-streaming approach, signal data can be viewed in SDI while the simulation is running, and exported to MAT, XLSX, or MLDATX file or post-processed after stopping the recording. See the links below for more details:
For more information on file I/O in Speedgoat real-time simulations, see: