MATLAB: How to log a signal for a long run (multiple days) in Simulink Real Time using File Scope

I wanted to run a simulation for few days, so I configure a File Scope on Simulink Real-Time to do so.
The sample time of my model is 5e-4 s so I needed 999 999 999 samples on my FileScope but it saved only 9 999 999 samples (i.e just more than one hour of simulation instead of 5 days).
I wonder if the memory that I wanted to allocated on the target machine would exceed the memory of the target machine.

Best Answer

Instead of logging all data in one file, consider logging the data in multiple files following this example:
In particular, go to the Scope Properties > File section and select Dynamic File Mode and AutoRestart. Then, you can configure Filename to increment dynamically. Use a base file name, an underscore (), and a < > specifier. Within the specifier, enter one to eight % symbols. Each symbol % represents a decimal location in the file name. The specifier can appear anywhere in the file name. For example, the following value for Filename, C:\work\file<%%%>.dat creates file names with the following pattern:
file_001.dat
file_002.dat
file_003.dat
The last file name of this series is file_999.dat. Note that if the block is still logging data when the last file reaches its maximum size, the function restarts and overwrites the first file in the series. If you do not retrieve the data from existing files before they are overwritten, the data is lost.
For more information about parameters in the Real-Time File Scope, please refer to this page: