You can use several options to reduce the amount of data logged during a simulation. Limiting the amount of exported simulation data reduces memory usage and speeds up simulation. However, if you limit the amount of simulation data, the logged data can skip some time steps that are critical for testing and analyzing the model.
You can use multiple techniques for the same simulation.
Technique | Description |
---|---|
Specify a decimation factor | Skip samples when exporting data. |
Limit data points | Limit the number of samples saved to be only the most recent samples |
Specify an interval for logging | Specify ranges of time steps for logging |
Alternatively, for logging large amounts of data that can cause memory issues, consider logging to persistent storage. This approach preserves all the logging data, minimizing MATLAB workspace memory usage. For details, see Log Data to Persistent Storage.
To skip samples when exporting data, apply a decimation factor. For example, a decimation factor of 2 saves every other sample. By default, decimation is set to 1, which does not skip any samples.
The approach you use to specify a decimation factor depends on the kind of logging data.
To limit the number of samples saved to be only the most recent samples, set the Limit Data Points parameter.
The approach you use depends on the kind of logging data.
Data | How to Specify |
---|---|
Signal logging | Right-click the signal. In the Signal Properties dialog box, select the Limit Data Points to Last parameter. |
Data store logging | From the Block Parameters dialog box for that block, open the Logging tab. Select the Limit Data Points to Last parameter. |
Time, state, and output logging | Select the Limit data points configuration parameter and for the Maximum number of data points configuration parameter, specify the limit. |
To specify an interval for logging, use the Configuration Parameters > Data Import/Export > Logging intervals parameter. Limiting logging to a specified interval allows you to examine specific logged data without changing the model or adding complexity to a model.
The logging intervals apply to data logged for:
Time
States
Output
Signal logging
The To Workspace block
The To File block
The logging intervals do not apply to final state logged data, scopes, or streaming data to the Simulation Data Inspector.
The intervals specified with Logging intervals establish the set of
times to which the Decimation and Limit data points to
last parameters apply. For example, suppose that you set the logging interval
[2,4;7,9]
with a fixed-step solver with a fixed-step size of 1. The
logged times are 2, 3, 4, 7, 8, and 9.