About Simulation Data Logging

Suggested Workflows

You can log simulation data to the workspace for debugging and verification. Data logging lets you analyze how internal block variables change with time during simulation. For example, you might want to see that the pressure in a hydraulic cylinder is above some minimum value or compare it against the pump pressure. If you log simulation data to the workspace, you can later query, plot, and analyze it without rerunning the simulation.

Simulation data logging can also replace connecting sensors and scopes to track simulation data. These blocks increase model complexity and slow down simulation. Log and Plot Simulation Data shows how you can log and plot simulation data instead of adding sensors to your model. It also shows how you can print the complete logging tree for a model and plot simulation results for a selected variable.

You can log data either for the whole model, or on a block-by-block basis. In the second case, the workspace variable will contain simulation data for selected blocks only. To log data for selected blocks only, you have to:

  • Set the logging configuration parameter

  • Select the blocks in your model

You can perform these two steps in any order. For more information, see Log Data for Selected Blocks Only.

After running the simulation, you can use the Simscape™ Results Explorer tool to navigate and plot the data logging results.

For additional information on how you can query, plot, and analyze data stored in the simulation log variable, see the reference pages for the classes simscape.logging.Node, simscape.logging.Series, and their associated methods.

You can also configure your model to automatically record Simscape logging data, along with the rest of the simulation data obtained from a model run, using the Simulation Data Inspector. Set up your model to log simulation data, either for the whole model or on a block-by-block basis, and enable data recording. Simulate the model, and then open the Simulation Data Inspector and view the results. For detailed information on how to enable data recording and how to configure and use the Simulation Data Inspector, see Inspect Signal Data with Simulation Data Inspector.

To make your model simulation and data logging compatible with the parfor command, select the Save simulation output as single object check box on the Data Import/Export pane of the Configuration Parameters dialog box. In this case, Simscape log data will be part of the single output object instead of being stored as a separate workspace variable. For more information, see Save simulation output as single object.


Simulation data logging is not supported for:

  • Model reference

  • Generated code

  • Accelerator mode

  • Rapid Accelerator mode

Related Examples

More About

Was this topic helpful?